diff options
author | Daniel Hillier <daniel.hillier@gmail.com> | 2021-09-23 21:37:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-23 21:37:53 (GMT) |
commit | 91099e25446b214725f8e2ffffbec6f90553260c (patch) | |
tree | accd914e2f290a671b7448ea31ffd104ac9e453b /Lib/zipfile.py | |
parent | 86b833badd3d6864868404ead2f8c7994d24f85c (diff) | |
download | cpython-91099e25446b214725f8e2ffffbec6f90553260c.zip cpython-91099e25446b214725f8e2ffffbec6f90553260c.tar.gz cpython-91099e25446b214725f8e2ffffbec6f90553260c.tar.bz2 |
bpo-39359: [zipfile] add missing "pwd: expected bytes, got str" exception (GH-18031)
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r-- | Lib/zipfile.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py index 3efeecb..8e9325b 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -1508,8 +1508,6 @@ class ZipFile: """ if mode not in {"r", "w"}: raise ValueError('open() requires mode "r" or "w"') - if pwd and not isinstance(pwd, bytes): - raise TypeError("pwd: expected bytes, got %s" % type(pwd).__name__) if pwd and (mode == "w"): raise ValueError("pwd is only supported for reading files") if not self.fp: @@ -1577,6 +1575,8 @@ class ZipFile: if is_encrypted: if not pwd: pwd = self.pwd + if pwd and not isinstance(pwd, bytes): + raise TypeError("pwd: expected bytes, got %s" % type(pwd).__name__) if not pwd: raise RuntimeError("File %r is encrypted, password " "required for extraction" % name) |