Skip to content

Commit 8a76d18

Browse files
committed
raise a TypeError if zipimport is called with a non-str
1 parent 0f024c5 commit 8a76d18

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Lib/zipimport.py

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ class zipimporter(_bootstrap_external._LoaderBasics):
6262
# entry in sys.path_importer_cache, fetch the file directory from there
6363
# if found, or else read it from the archive.
6464
def __init__(self, path):
65+
if not isinstance(path, str):
66+
raise TypeError(f"expected str, not {type(path)!r}")
6567
if not path:
6668
raise ZipImportError('archive path is empty', path=path)
6769
if alt_path_sep:

0 commit comments

Comments
 (0)