Skip to content

Commit 609d44f

Browse files
authored
Apply suggestions from code review
1 parent 54b7e31 commit 609d44f

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Lib/zipfile/__init__.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ class ZipFile:
13721372
""" Class with methods to open, read, write, close, list zip files.
13731373
13741374
z = ZipFile(file, mode="r", compression=ZIP_STORED, allowZip64=True,
1375-
compresslevel=None, _ZipInfo=ZipInfo, _ZipExtFile=ZipExtFile)
1375+
compresslevel=None, zipinfo_class=ZipInfo, zipextfile_class=ZipExtFile)
13761376
13771377
file: Either the path to the file, or a file-like object.
13781378
If it is a path, the file will be opened and closed by ZipFile.
@@ -1392,7 +1392,14 @@ class ZipFile:
13921392
When using ZIP_ZSTANDARD integers -7 though 22 are common,
13931393
see the CompressionParameter enum in compression.zstd for
13941394
details.
1395-
_ZipInfo: A class that can replace ZipInfo. This is designed to help extend
1395+
zipinfo_class: A class that can replace ZipInfo. This is designed to help
1396+
extend ZipFile.
1397+
For example, to implement other encryption or compression
1398+
methods.
1399+
zipextfile_class: A class that can replace ZipExtFile. This is designed to
1400+
help extend ZipFile.
1401+
For example to implement other encryption or compression
1402+
methods.
13961403
ZipFile, for example to implement other encryption or compression
13971404
methods.
13981405
This is private as there is no commitemnt to maintain backward
@@ -1409,15 +1416,15 @@ class ZipFile:
14091416

14101417
def __init__(self, file, mode="r", compression=ZIP_STORED, allowZip64=True,
14111418
compresslevel=None, *, strict_timestamps=True, metadata_encoding=None,
1412-
_ZipInfo=ZipInfo, _ZipExtFile=ZipExtFile):
1419+
zipinfo_class=ZipInfo, zipextfile_class=ZipExtFile):
14131420
"""Open the ZIP file with mode read 'r', write 'w', exclusive create 'x',
14141421
or append 'a'."""
14151422
if mode not in ('r', 'w', 'x', 'a'):
14161423
raise ValueError("ZipFile requires mode 'r', 'w', 'x', or 'a'")
14171424

14181425
_check_compression(compression)
1419-
self._ZipInfo = _ZipInfo
1420-
self._ZipExtFile = _ZipExtFile
1426+
self._ZipInfo = zipinfo_class
1427+
self._ZipExtFile = zipextfile_class
14211428
self._allowZip64 = allowZip64
14221429
self._didModify = False
14231430
self.debug = 0 # Level of printing: 0 through 3

0 commit comments

Comments
 (0)