mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-34097: Polish API design (GH-8725)
Move strict_timestamps to constructor.
This commit is contained in:
parent
1b5f9c9653
commit
77b112cd56
3 changed files with 19 additions and 18 deletions
|
@ -1151,7 +1151,7 @@ class ZipFile:
|
|||
_windows_illegal_name_trans_table = None
|
||||
|
||||
def __init__(self, file, mode="r", compression=ZIP_STORED, allowZip64=True,
|
||||
compresslevel=None):
|
||||
compresslevel=None, *, strict_timestamps=True):
|
||||
"""Open the ZIP file with mode read 'r', write 'w', exclusive create 'x',
|
||||
or append 'a'."""
|
||||
if mode not in ('r', 'w', 'x', 'a'):
|
||||
|
@ -1169,6 +1169,7 @@ class ZipFile:
|
|||
self.mode = mode
|
||||
self.pwd = None
|
||||
self._comment = b''
|
||||
self._strict_timestamps = strict_timestamps
|
||||
|
||||
# Check if we were passed a file-like object
|
||||
if isinstance(file, os.PathLike):
|
||||
|
@ -1677,8 +1678,7 @@ class ZipFile:
|
|||
" would require ZIP64 extensions")
|
||||
|
||||
def write(self, filename, arcname=None,
|
||||
compress_type=None, compresslevel=None, *,
|
||||
strict_timestamps=True):
|
||||
compress_type=None, compresslevel=None):
|
||||
"""Put the bytes from filename into the archive under the name
|
||||
arcname."""
|
||||
if not self.fp:
|
||||
|
@ -1690,7 +1690,7 @@ class ZipFile:
|
|||
)
|
||||
|
||||
zinfo = ZipInfo.from_file(filename, arcname,
|
||||
strict_timestamps=strict_timestamps)
|
||||
strict_timestamps=self._strict_timestamps)
|
||||
|
||||
if zinfo.is_dir():
|
||||
zinfo.compress_size = 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue