summaryrefslogtreecommitdiffstats
path: root/Lib/zipfile.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-02 17:51:37 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-02 17:51:37 (GMT)
commit672671da47582101060819f94eb054fa344c6e5c (patch)
tree1f1b9eabb5a62d369d61af27956756e723439deb /Lib/zipfile.py
parentd357a3f841ee41cee55575b5729658b5ecd45902 (diff)
parente5e64444979f0bb6c922f1c2742440f964ce6801 (diff)
downloadcpython-672671da47582101060819f94eb054fa344c6e5c.zip
cpython-672671da47582101060819f94eb054fa344c6e5c.tar.gz
cpython-672671da47582101060819f94eb054fa344c6e5c.tar.bz2
Fix the test for issue #6972.
Remove trailing dots on Windows.
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r--Lib/zipfile.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index f5c3f17..8b355d6 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -1238,11 +1238,14 @@ class ZipFile:
arcname = os.path.splitdrive(arcname)[1]
arcname = os.path.sep.join(x for x in arcname.split(os.path.sep)
if x not in ('', os.path.curdir, os.path.pardir))
- # filter illegal characters on Windows
if os.path.sep == '\\':
+ # filter illegal characters on Windows
illegal = ':<>|"?*'
table = str.maketrans(illegal, '_' * len(illegal))
arcname = arcname.translate(table)
+ # remove trailing dots
+ arcname = (x.rstrip('.') for x in arcname.split(os.path.sep))
+ arcname = os.path.sep.join(x for x in arcname if x)
targetpath = os.path.join(targetpath, arcname)
targetpath = os.path.normpath(targetpath)