[Python-checkins] cpython (merge 3.5 -> default): Issue #5784: Merge zlib from 3.5

martin.panter python-checkins at python.org
Fri May 27 07:33:21 EDT 2016


https://hg.python.org/cpython/rev/1771f0ac9fc2
changeset:   101525:1771f0ac9fc2
parent:      101522:4d4f27fc70d5
parent:      101524:ca49614989dd
user:        Martin Panter <vadmium+py at gmail.com>
date:        Fri May 27 11:30:59 2016 +0000
summary:
  Issue #5784: Merge zlib from 3.5

files:
  Doc/library/zlib.rst  |   1 +
  Lib/test/test_zlib.py |  13 +++++++++++--
  2 files changed, 12 insertions(+), 2 deletions(-)


diff --git a/Doc/library/zlib.rst b/Doc/library/zlib.rst
--- a/Doc/library/zlib.rst
+++ b/Doc/library/zlib.rst
@@ -147,6 +147,7 @@
      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
--- a/Lib/test/test_zlib.py
+++ b/Lib/test/test_zlib.py
@@ -685,10 +685,18 @@
             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)
@@ -702,7 +710,8 @@
         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)

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list