Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit de8ff78

Browse filesBrowse files
committed
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.
1 parent 56f9844 commit de8ff78
Copy full SHA for de8ff78

File tree

2 files changed

+4
-0
lines changed
Filter options

2 files changed

+4
-0
lines changed

‎Lib/zipfile.py

Copy file name to clipboardExpand all lines: Lib/zipfile.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)):
380380
# ZIP format specification.
381381
if os.sep != "/" and os.sep in filename:
382382
filename = filename.replace(os.sep, "/")
383+
if os.altsep and os.altsep != "/" and os.altsep in filename:
384+
filename = filename.replace(os.altsep, "/")
383385

384386
self.filename = filename # Normalized file name
385387
self.date_time = date_time # year, month, day, hour, min, sec
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
When creating zip files using the ``zipfile`` module, ``os.altsep`` will always
2+
be treated as a path separator. Patch by Carey Metcalfe.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.