Skip to content

Commit 697a07a

Browse files
Document that zipfile's pwd parameter is a bytes object (GH-100209)
(cherry picked from commit 5ee7eb9) Co-authored-by: JustAnotherArchivist <[email protected]>
1 parent 3144aca commit 697a07a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Doc/library/zipfile.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ ZipFile Objects
251251
Access a member of the archive as a binary file-like object. *name*
252252
can be either the name of a file within the archive or a :class:`ZipInfo`
253253
object. The *mode* parameter, if included, must be ``'r'`` (the default)
254-
or ``'w'``. *pwd* is the password used to decrypt encrypted ZIP files.
254+
or ``'w'``. *pwd* is the password used to decrypt encrypted ZIP files as a
255+
:class:`bytes` object.
255256

256257
:meth:`~ZipFile.open` is also a context manager and therefore supports the
257258
:keyword:`with` statement::
@@ -303,7 +304,7 @@ ZipFile Objects
303304
must be its full name or a :class:`ZipInfo` object. Its file information is
304305
extracted as accurately as possible. *path* specifies a different directory
305306
to extract to. *member* can be a filename or a :class:`ZipInfo` object.
306-
*pwd* is the password used for encrypted files.
307+
*pwd* is the password used for encrypted files as a :class:`bytes` object.
307308

308309
Returns the normalized path created (a directory or new file).
309310

@@ -330,7 +331,7 @@ ZipFile Objects
330331
Extract all members from the archive to the current working directory. *path*
331332
specifies a different directory to extract to. *members* is optional and must
332333
be a subset of the list returned by :meth:`namelist`. *pwd* is the password
333-
used for encrypted files.
334+
used for encrypted files as a :class:`bytes` object.
334335

335336
.. warning::
336337

@@ -355,16 +356,16 @@ ZipFile Objects
355356

356357
.. method:: ZipFile.setpassword(pwd)
357358

358-
Set *pwd* as default password to extract encrypted files.
359+
Set *pwd* (a :class:`bytes` object) as default password to extract encrypted files.
359360

360361

361362
.. method:: ZipFile.read(name, pwd=None)
362363

363364
Return the bytes of the file *name* in the archive. *name* is the name of the
364365
file in the archive, or a :class:`ZipInfo` object. The archive must be open for
365-
read or append. *pwd* is the password used for encrypted files and, if specified,
366-
it will override the default password set with :meth:`setpassword`. Calling
367-
:meth:`read` on a ZipFile that uses a compression method other than
366+
read or append. *pwd* is the password used for encrypted files as a :class:`bytes`
367+
object and, if specified, overrides the default password set with :meth:`setpassword`.
368+
Calling :meth:`read` on a ZipFile that uses a compression method other than
368369
:const:`ZIP_STORED`, :const:`ZIP_DEFLATED`, :const:`ZIP_BZIP2` or
369370
:const:`ZIP_LZMA` will raise a :exc:`NotImplementedError`. An error will also
370371
be raised if the corresponding compression module is not available.

0 commit comments

Comments
 (0)