Merged revisions 81098 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r81098 | antoine.pitrou | 2010-05-12 01:42:28 +0200 (mer., 12 mai 2010) | 5 lines
Issue #8681: Make the zlib module's error messages more informative when
the zlib itself doesn't give any detailed explanation.
........
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py
index 9137f8a..1b802b8 100644
--- a/Lib/test/test_zlib.py
+++ b/Lib/test/test_zlib.py
@@ -134,6 +134,18 @@
x = zlib.compress(data)
self.assertEqual(zlib.decompress(x), data)
+ def test_incomplete_stream(self):
+ # An useful error message is given
+ x = zlib.compress(HAMLET_SCENE)
+ try:
+ zlib.decompress(x[:-1])
+ except zlib.error as e:
+ self.assertTrue(
+ "Error -5 while decompressing data: incomplete or truncated stream"
+ in str(e), str(e))
+ else:
+ self.fail("zlib.error not raised")
+
# Memory use of the following functions takes into account overallocation
@precisionbigmemtest(size=_1G + 1024 * 1024, memuse=3)