diff --git a/Lib/zipfile/__init__.py b/Lib/zipfile/__init__.py index 95c047991f8..116b939e55f 100644 --- a/Lib/zipfile/__init__.py +++ b/Lib/zipfile/__init__.py @@ -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 diff --git a/Misc/NEWS.d/next/Library/2022-05-02-16-21-05.gh-issue-92184.hneGVW.rst b/Misc/NEWS.d/next/Library/2022-05-02-16-21-05.gh-issue-92184.hneGVW.rst new file mode 100644 index 00000000000..65dbdc9f603 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-05-02-16-21-05.gh-issue-92184.hneGVW.rst @@ -0,0 +1,3 @@ +When creating zip files using :mod:`zipfile`, ``os.altsep``, if not ``None``, +will always be treated as a path separator even when it is not ``/``. +Patch by Carey Metcalfe.