Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Lib/zipfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2084,7 +2084,10 @@
flags = centdir[_CD_FLAG_BITS]
if flags & _MASK_UTF_FILENAME:
# UTF-8 file names extension
filename = filename.decode('utf-8')
try:
filename = filename.decode('utf-8')
except UnicodeDecodeError as e:
raise BadZipFile("Invalid UTF-8 filename in central directory") from e
else:
# Historical ZIP filename encoding
filename = filename.decode(self.metadata_encoding or 'cp437')
Expand Down Expand Up @@ -2264,8 +2267,11 @@

if fheader[_FH_GENERAL_PURPOSE_FLAG_BITS] & _MASK_UTF_FILENAME:
# UTF-8 filename
try:
fname_str = fname.decode("utf-8")

Check failure on line 2271 in Lib/zipfile/__init__.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/zipfile/__init__.py:2271:17: invalid-syntax: Expected an indented block after `try` statement
except UnicodeDecodeError as e:
raise BadZipFile("Invalid UTF-8 filename in local file header") from e
else:

Check failure on line 2274 in Lib/zipfile/__init__.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/zipfile/__init__.py:2274:13: invalid-syntax: Expected dedent, found `else`
fname_str = fname.decode(self.metadata_encoding or "cp437")

if fname_str != zinfo.orig_filename:
Expand Down Expand Up @@ -2299,11 +2305,11 @@
pwd = None

return ZipExtFile(zef_file, mode + 'b', zinfo, pwd, True)
except:

Check failure on line 2308 in Lib/zipfile/__init__.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/zipfile/__init__.py:2308:15: invalid-syntax: Expected a statement

Check failure on line 2308 in Lib/zipfile/__init__.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/zipfile/__init__.py:2308:9: invalid-syntax: Expected a statement
zef_file.close()

Check failure on line 2309 in Lib/zipfile/__init__.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/zipfile/__init__.py:2309:1: invalid-syntax: Unexpected indentation

Check failure on line 2309 in Lib/zipfile/__init__.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/zipfile/__init__.py:2308:16: invalid-syntax: Expected a statement
raise

def _open_to_write(self, zinfo, force_zip64=False):

Check failure on line 2312 in Lib/zipfile/__init__.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/zipfile/__init__.py:2312:5: invalid-syntax: Expected a statement
if force_zip64 and not self._allowZip64:
raise ValueError(
"force_zip64 is True, but allowZip64 was False when opening "
Expand Down Expand Up @@ -2780,7 +2786,7 @@
fp.close()


class PyZipFile(ZipFile):

Check failure on line 2789 in Lib/zipfile/__init__.py

View workflow job for this annotation

GitHub Actions / lint

ruff (invalid-syntax)

Lib/zipfile/__init__.py:2789:1: invalid-syntax: Expected a statement
"""Class to create ZIP archives with Python library files and packages."""

def __init__(self, file, mode="r", compression=ZIP_STORED,
Expand Down
Loading