Issue #20875: Merge from 3.3

This commit is contained in:
Ned Deily 2014-03-09 14:47:58 -07:00
commit e5127299c8
3 changed files with 11 additions and 1 deletions

View File

@ -96,7 +96,7 @@ class _PaddedFile:
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

View File

@ -421,6 +421,13 @@ class TestGzip(BaseTest):
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

View File

@ -20,6 +20,9 @@ Core and Builtins
Library
-------
- Issue #20875: Prevent possible gzip "'read' is not defined" NameError.
Patch by Claudiu Popa.
- Issue #11558: ``email.message.Message.attach`` now returns a more
useful error message if ``attach`` is called on a message for which
``is_multipart`` is False.