[Jython-checkins] jython: #1753: zlib doesn't call end() on compress and decompress. Thanks to Kelly

alan.kennedy jython-checkins at python.org
Sun Feb 10 12:50:16 CET 2013


http://hg.python.org/jython/rev/d39b428d5c99
changeset:   7028:d39b428d5c99
user:        Alan Kennedy <alan at xhaus.com>
date:        Sun Feb 10 11:46:10 2013 +0000
summary:
  #1753: zlib doesn't call end() on compress and decompress. Thanks to Kelly Campbell for the patch

files:
  Lib/zlib.py |  19 ++++++++++++-------
  1 files changed, 12 insertions(+), 7 deletions(-)


diff --git a/Lib/zlib.py b/Lib/zlib.py
--- a/Lib/zlib.py
+++ b/Lib/zlib.py
@@ -61,16 +61,21 @@
     if level < Z_BEST_SPEED or level > Z_BEST_COMPRESSION:
         raise error, "Bad compression level"
     deflater = Deflater(level, 0)
-    string = _to_input(string)
-    deflater.setInput(string, 0, len(string))
-    deflater.finish()
-    return _get_deflate_data(deflater)
+    try:
+        string = _to_input(string)
+        deflater.setInput(string, 0, len(string))
+        deflater.finish()
+        return _get_deflate_data(deflater)
+    finally:
+        deflater.end()
 
 def decompress(string, wbits=0, bufsize=16384):
     inflater = Inflater(wbits < 0)
-    inflater.setInput(_to_input(string))
-
-    return _get_inflate_data(inflater)
+    try:
+        inflater.setInput(_to_input(string))
+        return _get_inflate_data(inflater)
+    finally:
+        inflater.end()
 
 class compressobj:
     # all jython uses wbits for is deciding whether to skip the header if it's negative

-- 
Repository URL: http://hg.python.org/jython


More information about the Jython-checkins mailing list