mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-108111: Flush gzip write buffer before seeking, fixing bad writes (#108341)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
This commit is contained in:
parent
aa9a359ca2
commit
2eb60c1934
4 changed files with 18 additions and 0 deletions
|
@ -665,6 +665,18 @@ class TestGzip(BaseTest):
|
|||
]
|
||||
self.assertEqual(fc.modes, expected_modes)
|
||||
|
||||
def test_write_seek_write(self):
|
||||
# Make sure that offset is up-to-date before seeking
|
||||
# See issue GH-108111
|
||||
b = io.BytesIO()
|
||||
message = b"important message here."
|
||||
with gzip.GzipFile(fileobj=b, mode='w') as f:
|
||||
f.write(message)
|
||||
f.seek(len(message))
|
||||
f.write(message)
|
||||
data = b.getvalue()
|
||||
self.assertEqual(gzip.decompress(data), message * 2)
|
||||
|
||||
|
||||
class TestOpen(BaseTest):
|
||||
def test_binary_modes(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue