Issue #20875: Prevent possible gzip "'read' is not defined" NameError.
Patch by Claudiu Popa.
This commit is contained in:
parent
5e572fd490
commit
6120739f0c
|
@ -99,7 +99,7 @@ class _PaddedFile:
|
||||||
self._read -= len(prepend)
|
self._read -= len(prepend)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self._buffer = self._buffer[read:] + prepend
|
self._buffer = self._buffer[self._read:] + prepend
|
||||||
self._length = len(self._buffer)
|
self._length = len(self._buffer)
|
||||||
self._read = 0
|
self._read = 0
|
||||||
|
|
||||||
|
|
|
@ -396,6 +396,13 @@ class TestGzip(BaseTest):
|
||||||
with gzip.GzipFile(fileobj=io.BytesIO(gzdata)) as f:
|
with gzip.GzipFile(fileobj=io.BytesIO(gzdata)) as f:
|
||||||
self.assertEqual(f.read(), b'Test')
|
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):
|
class TestOpen(BaseTest):
|
||||||
def test_binary_modes(self):
|
def test_binary_modes(self):
|
||||||
uncompressed = data1 * 50
|
uncompressed = data1 * 50
|
||||||
|
|
|
@ -13,6 +13,9 @@ Core and Builtins
|
||||||
Library
|
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
|
- Issue #20283: RE pattern methods now accept the string keyword parameters
|
||||||
as documented. The pattern and source keyword parameters are left as
|
as documented. The pattern and source keyword parameters are left as
|
||||||
deprecated aliases.
|
deprecated aliases.
|
||||||
|
|
Loading…
Reference in New Issue