summaryrefslogtreecommitdiffstats
path: root/Lib/gzip.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-08-24 10:30:16 (GMT)
committerGitHub <noreply@github.com>2023-08-24 10:30:16 (GMT)
commit20357ed2a434fc59a9cd33c162594e8f792813b4 (patch)
tree99cf016bdddc97891d066bd767835189522848af /Lib/gzip.py
parent459f24aef09dce122362ee2f234e97916cbf1e8d (diff)
downloadcpython-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/gzip.py')
-rw-r--r--Lib/gzip.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py
index cf8b675..177f908 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -401,6 +401,9 @@ class GzipFile(_compression.BaseStream):
def seek(self, offset, whence=io.SEEK_SET):
if self.mode == WRITE:
+ self._check_not_closed()
+ # Flush buffer to ensure validity of self.offset
+ self._buffer.flush()
if whence != io.SEEK_SET:
if whence == io.SEEK_CUR:
offset = self.offset + offset