summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-05-27 11:20:21 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-05-27 11:20:21 (GMT)
commitc618ae8ed79cf391efa62b7d0ed571882a4356f9 (patch)
tree573c93ccd5a6fab4053dfff7355c95cf0f989127
parent0fdf41d847335e108652bbf4e9e9be9855e20005 (diff)
downloadcpython-c618ae8ed79cf391efa62b7d0ed571882a4356f9.zip
cpython-c618ae8ed79cf391efa62b7d0ed571882a4356f9.tar.gz
cpython-c618ae8ed79cf391efa62b7d0ed571882a4356f9.tar.bz2
Issue #5784: wbits=0 apparently added in zlib v1.2.3.5
-rw-r--r--Doc/library/zlib.rst1
-rw-r--r--Lib/test/test_zlib.py13
2 files changed, 12 insertions, 2 deletions
diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst
index 565f3f7..b7ca558 100644
--- a/Doc/library/zlib.rst
+++ b/Doc/library/zlib.rst
@@ -142,6 +142,7 @@ The available exception and functions in this module are:
must include a zlib header and trailer.
* 0: Automatically determine the window size from the zlib header.
+ Only supported since zlib 1.2.3.5.
* −8 to −15: Uses the absolute value of *wbits* as the window size
logarithm. The input must be a raw stream with no header or trailer.
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py
index 72a1596..b6bebbc 100644
--- a/Lib/test/test_zlib.py
+++ b/Lib/test/test_zlib.py
@@ -681,10 +681,18 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
data = None
def test_wbits(self):
+ # wbits=0 only supported since zlib v1.2.3.5
+ # Register "1.2.3" as "1.2.3.0"
+ v = (zlib.ZLIB_RUNTIME_VERSION + ".0").split(".", 4)
+ supports_wbits_0 = int(v[0]) > 1 or int(v[0]) == 1 \
+ and (int(v[1]) > 2 or int(v[1]) == 2
+ and (int(v[2]) > 3 or int(v[2]) == 3 and int(v[3]) >= 5))
+
co = zlib.compressobj(level=1, wbits=15)
zlib15 = co.compress(HAMLET_SCENE) + co.flush()
self.assertEqual(zlib.decompress(zlib15, 15), HAMLET_SCENE)
- self.assertEqual(zlib.decompress(zlib15, 0), HAMLET_SCENE)
+ if supports_wbits_0:
+ self.assertEqual(zlib.decompress(zlib15, 0), HAMLET_SCENE)
self.assertEqual(zlib.decompress(zlib15, 32 + 15), HAMLET_SCENE)
with self.assertRaisesRegex(zlib.error, 'invalid window size'):
zlib.decompress(zlib15, 14)
@@ -698,7 +706,8 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
zlib9 = co.compress(HAMLET_SCENE) + co.flush()
self.assertEqual(zlib.decompress(zlib9, 9), HAMLET_SCENE)
self.assertEqual(zlib.decompress(zlib9, 15), HAMLET_SCENE)
- self.assertEqual(zlib.decompress(zlib9, 0), HAMLET_SCENE)
+ if supports_wbits_0:
+ self.assertEqual(zlib.decompress(zlib9, 0), HAMLET_SCENE)
self.assertEqual(zlib.decompress(zlib9, 32 + 9), HAMLET_SCENE)
dco = zlib.decompressobj(wbits=32 + 9)
self.assertEqual(dco.decompress(zlib9), HAMLET_SCENE)