Skip to content

Commit

Permalink
more more _sanitize_filename, this time zi.from_file
Browse files Browse the repository at this point in the history
if a PathLike may be used as arcname.
  • Loading branch information
gpshead committed Dec 22, 2023
1 parent eb7a1c4 commit 358ccbe
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Lib/zipfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,10 @@ def from_file(cls, filename, arcname=None, *, strict_timestamps=True):
"""
if isinstance(filename, os.PathLike):
filename = os.fspath(filename)
if isinstance(arcname, os.PathLike):
arcname = os.fspath(arcname)
if arcname is None:
arcname = _sanitize_filename(filename)
elif isinstance(arcname, os.PathLike):
arcname = _sanitize_filename(os.fspath(arcname))
st = os.stat(filename)
isdir = stat.S_ISDIR(st.st_mode)
mtime = time.localtime(st.st_mtime)
Expand Down

0 comments on commit 358ccbe

Please sign in to comment.