diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-08-24 10:30:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-24 10:30:16 (GMT) |
commit | 20357ed2a434fc59a9cd33c162594e8f792813b4 (patch) | |
tree | 99cf016bdddc97891d066bd767835189522848af /Lib/test/test_gzip.py | |
parent | 459f24aef09dce122362ee2f234e97916cbf1e8d (diff) | |
download | cpython-20357ed2a434fc59a9cd33c162594e8f792813b4.zip cpython-20357ed2a434fc59a9cd33c162594e8f792813b4.tar.gz cpython-20357ed2a434fc59a9cd33c162594e8f792813b4.tar.bz2 |
[3.12] gh-108111: Flush gzip write buffer before seeking, fixing bad writes (GH-108341) (#108402)
gh-108111: Flush gzip write buffer before seeking, fixing bad writes (GH-108341)
(cherry picked from commit 2eb60c1934f47671e6b3c9b90b6d9f1912d829a0)
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Lib/test/test_gzip.py')
-rw-r--r-- | Lib/test/test_gzip.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index b06b3b0..128f933 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -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): |