Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e465a9a

Browse files
Issue #29094: Offsets in a ZIP file created with extern file object and modes
"w" and "x" now are relative to the start of the file.
2 parents 75d9016 + 34cba33 commit e465a9a

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

Lib/zipfile.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,11 +1102,12 @@ def __init__(self, file, mode="r", compression=ZIP_STORED, allowZip64=True):
11021102
# set the modified flag so central directory gets written
11031103
# even if no files are added to the archive
11041104
self._didModify = True
1105+
self._start_disk = 0
11051106
try:
1106-
self.start_dir = self._start_disk = self.fp.tell()
1107+
self.start_dir = self.fp.tell()
11071108
except (AttributeError, OSError):
11081109
self.fp = _Tellable(self.fp)
1109-
self.start_dir = self._start_disk = 0
1110+
self.start_dir = 0
11101111
self._seekable = False
11111112
else:
11121113
# Some file-like objects can provide tell() but not seek()

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ Core and Builtins
4040
Library
4141
-------
4242

43+
- Issue #29094: Offsets in a ZIP file created with extern file object and modes
44+
"w" and "x" now are relative to the start of the file.
45+
4346
- Issue #29085: Allow random.Random.seed() to use high quality OS randomness
4447
rather than the pid and time.
4548

0 commit comments

Comments
 (0)