mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +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
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue