[Python-checkins] cpython (3.3): Issue #20875: Prevent possible gzip "'read' is not defined" NameError.
ned.deily
python-checkins at python.org
Sun Mar 9 22:48:32 CET 2014
http://hg.python.org/cpython/rev/c3836de644e0
changeset: 89534:c3836de644e0
branch: 3.3
parent: 89524:95d8ca61cdbf
user: Ned Deily <nad at acm.org>
date: Sun Mar 09 14:44:34 2014 -0700
summary:
Issue #20875: Prevent possible gzip "'read' is not defined" NameError.
Patch by Claudiu Popa.
files:
Lib/gzip.py | 2 +-
Lib/test/test_gzip.py | 7 +++++++
Misc/NEWS | 3 +++
3 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/Lib/gzip.py b/Lib/gzip.py
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -99,7 +99,7 @@
self._read -= len(prepend)
return
else:
- self._buffer = self._buffer[read:] + prepend
+ self._buffer = self._buffer[self._read:] + prepend
self._length = len(self._buffer)
self._read = 0
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py
--- a/Lib/test/test_gzip.py
+++ b/Lib/test/test_gzip.py
@@ -396,6 +396,13 @@
with gzip.GzipFile(fileobj=io.BytesIO(gzdata)) as f:
self.assertEqual(f.read(), b'Test')
+ def test_prepend_error(self):
+ # See issue #20875
+ with gzip.open(self.filename, "wb") as f:
+ f.write(data1)
+ with gzip.open(self.filename, "rb") as f:
+ f.fileobj.prepend()
+
class TestOpen(BaseTest):
def test_binary_modes(self):
uncompressed = data1 * 50
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -13,6 +13,9 @@
Library
-------
+- Issue #20875: Prevent possible gzip "'read' is not defined" NameError.
+ Patch by Claudiu Popa.
+
- Issue #20283: RE pattern methods now accept the string keyword parameters
as documented. The pattern and source keyword parameters are left as
deprecated aliases.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list