Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Convert os.altsep to '/' in filenames when creating ZipInfo objects
This causes the zipfile module to also consider the character defined by
`os.altsep` (if there is one) to be a path separator and convert it to a
forward slash, as defined by the zip specification.
  • Loading branch information
pR0Ps committed Apr 24, 2023
commit c0fa220c936cff6e49ca767cb702d9169560d317
2 changes: 2 additions & 0 deletions Lib/zipfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ def _sanitize_filename(filename):
# ZIP format specification.
if os.sep != "/" and os.sep in filename:
filename = filename.replace(os.sep, "/")
if os.altsep and os.altsep != "/" and os.altsep in filename:
filename = filename.replace(os.altsep, "/")
return filename


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
When creating zip files using the ``zipfile`` module, ``os.altsep`` will always
be treated as a path separator. Patch by Carey Metcalfe.