Skip to content

Commit

Permalink
move the fix into _SharedFile
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaryaz committed Dec 13, 2024
1 parent 57af21a commit 613945d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Lib/zipfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,10 @@ def seek(self, offset, whence=0):
raise ValueError("Can't reposition in the ZIP file while "
"there is an open writing handle on it. "
"Close the writing handle before trying to read.")
self._file.seek(offset, whence)
if whence == os.SEEK_CUR:
self._file.seek(self._pos + offset)
else:
self._file.seek(offset, whence)
self._pos = self._file.tell()
return self._pos

Expand Down Expand Up @@ -1167,7 +1170,7 @@ def seek(self, offset, whence=os.SEEK_SET):
self._expected_crc = None
# seek actual file taking already buffered data into account
read_offset -= len(self._readbuffer) - self._offset
self._fileobj.seek(self._orig_compress_start + read_offset)
self._fileobj.seek(read_offset, os.SEEK_CUR)
self._left -= read_offset
read_offset = 0
# flush read buffer
Expand Down

0 comments on commit 613945d

Please sign in to comment.