Issue #5692: In :class:`zipfile.Zipfile`, fix wrong path calculation when extracting a file to the root directory.
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index 3106353..a1e44c0 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -952,7 +952,9 @@
"""
# build the destination pathname, replacing
# forward slashes to platform specific separators.
- if targetpath[-1:] in (os.path.sep, os.path.altsep):
+ # Strip trailing path separator, unless it represents the root.
+ if (targetpath[-1:] in (os.path.sep, os.path.altsep)
+ and len(os.path.splitdrive(targetpath)[1]) > 1):
targetpath = targetpath[:-1]
# don't include leading "/" from file name if present