[pypy-commit] pypy default: Merge zlib-copying-redux
Julian Berman
pypy.commits at gmail.com
Wed Feb 6 06:07:07 EST 2019
Author: Julian Berman <Julian+Hg at GrayVines.com>
Branch:
Changeset: r95865:ec33801be3ff
Date: 2019-02-06 11:43 +0100
http://bitbucket.org/pypy/pypy/changeset/ec33801be3ff/
Log: Merge zlib-copying-redux
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -5,6 +5,10 @@
.. this is a revision shortly after release-pypy-7.0.0
.. startrev: 481c69f7d81f
+.. branch: zlib-copying-redux
+
+Fix calling copy on already-flushed compressobjs.
+
.. branch: zlib-copying
The zlib module's compressobj and decompressobj now expose copy methods
diff --git a/pypy/module/zlib/interp_zlib.py b/pypy/module/zlib/interp_zlib.py
--- a/pypy/module/zlib/interp_zlib.py
+++ b/pypy/module/zlib/interp_zlib.py
@@ -175,6 +175,11 @@
try:
self.lock()
try:
+ if not self.stream:
+ raise oefmt(
+ space.w_ValueError,
+ "Compressor was already flushed",
+ )
copied = rzlib.deflateCopy(self.stream)
finally:
self.unlock()
@@ -318,9 +323,6 @@
try:
self.lock()
try:
- if not self.stream:
- raise zlib_error(space,
- "decompressor object already flushed")
copied = rzlib.inflateCopy(self.stream)
finally:
self.unlock()
diff --git a/pypy/module/zlib/test/test_zlib.py b/pypy/module/zlib/test/test_zlib.py
--- a/pypy/module/zlib/test/test_zlib.py
+++ b/pypy/module/zlib/test/test_zlib.py
@@ -307,7 +307,8 @@
assert (d1 + from_copy) == (d1 + from_decompressor)
- def test_unsuccessful_decompress_copy(self):
+ def test_cannot_copy_decompressor_with_stream_in_inconsistent_state(self):
+ if self.runappdirect: skip("can't run with -A")
decompressor = self.zlib.decompressobj()
self.intentionally_break_a_z_stream(zobj=decompressor)
raises(self.zlib.error, decompressor.copy)
@@ -341,7 +342,13 @@
assert (d1 + from_copy) == (d1 + from_compressor)
- def test_unsuccessful_compress_copy(self):
+ def test_cannot_copy_compressor_with_stream_in_inconsistent_state(self):
+ if self.runappdirect: skip("can't run with -A")
compressor = self.zlib.compressobj()
self.intentionally_break_a_z_stream(zobj=compressor)
raises(self.zlib.error, compressor.copy)
+
+ def test_cannot_copy_compressor_with_flushed_stream(self):
+ compressor = self.zlib.compressobj()
+ compressor.flush()
+ raises(ValueError, compressor.copy)
More information about the pypy-commit
mailing list