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 6957930

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 c00faf7 commit 6957930
Copy full SHA for 6957930

File tree

2 files changed

+4
-0
lines changed
Filter options

2 files changed

+4
-0
lines changed

‎Lib/zipfile/__init__.py

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

380382
self.filename = filename # Normalized file name
381383
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.