diff options
| author | Sviatoslav Sydorenko <wk@sydorenko.org.ua> | 2020-11-15 01:21:55 +0100 |
|---|---|---|
| committer | Sviatoslav Sydorenko <wk@sydorenko.org.ua> | 2020-11-15 02:58:16 +0100 |
| commit | b4eb20e5803ccf11d5a84044ada8ebc6dc411ab1 (patch) | |
| tree | 586686824ddbd5d52f3b22546cb414659f376ca1 /cherrypy/test | |
| parent | 05ee11a96940817e471cce3675ac1fb1810f11e8 (diff) | |
| download | cherrypy-git-bugfixes/1849-gzip-compression-header-cpython-bug39389.tar.gz | |
Fix compression level in meta header in gzip toolbugfixes/1849-gzip-compression-header-cpython-bug39389
* https://bugs.python.org/issue39389
* https://github.com/python/cpython/pull/18077
* https://github.com/python/cpython/pull/18100
* https://github.com/python/cpython/pull/18101
Fixes #1849
Diffstat (limited to 'cherrypy/test')
| -rw-r--r-- | cherrypy/test/test_tools.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cherrypy/test/test_tools.py b/cherrypy/test/test_tools.py index 3a0fd389..be8a4798 100644 --- a/cherrypy/test/test_tools.py +++ b/cherrypy/test/test_tools.py @@ -15,6 +15,16 @@ from cherrypy._cpcompat import ntou from cherrypy.test import helper, _test_decorators +*PY_VER_MINOR, _ = PY_VER_PATCH = sys.version_info[:3] +# Refs: +# bugs.python.org/issue39389 +# docs.python.org/3.7/whatsnew/changelog.html#python-3-7-7-release-candidate-1 +# docs.python.org/3.8/whatsnew/changelog.html#python-3-8-2-release-candidate-1 +HAS_GZIP_COMPRESSION_HEADER_FIXED = PY_VER_PATCH >= (3, 8, 2) or ( + PY_VER_MINOR == (3, 7) and PY_VER_PATCH >= (3, 7, 7) +) + + timeout = 0.2 europoundUnicode = ntou('\x80\xa3') @@ -357,6 +367,13 @@ class ToolTests(helper.CPWebCase): ('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7')]) self.assertInBody(zbuf.getvalue()[:3]) + if not HAS_GZIP_COMPRESSION_HEADER_FIXED: + # NOTE: CherryPy adopts a fix from the CPython bug 39389 + # NOTE: introducing a variable compression XFL flag that + # NOTE: was hardcoded to "best compression" before. And so + # NOTE: we can only test it on CPython versions that also + # NOTE: implement this fix. + return zbuf = io.BytesIO() zfile = gzip.GzipFile(mode='wb', fileobj=zbuf, compresslevel=6) zfile.write(expectedResult) |
