Skip to content

Commit 4cfd007

Browse files
committed
move the fix into _SharedFile
1 parent 2835a4a commit 4cfd007

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Lib/zipfile/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,10 @@ def seek(self, offset, whence=0):
819819
raise ValueError("Can't reposition in the ZIP file while "
820820
"there is an open writing handle on it. "
821821
"Close the writing handle before trying to read.")
822-
self._file.seek(offset, whence)
822+
if whence == os.SEEK_CUR:
823+
self._file.seek(self._pos + offset)
824+
else:
825+
self._file.seek(offset, whence)
823826
self._pos = self._file.tell()
824827
return self._pos
825828

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

0 commit comments

Comments
 (0)