summaryrefslogtreecommitdiffstats
path: root/Lib/zipfile.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-02-02 17:50:59 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-02-02 17:50:59 (GMT)
commite5e64444979f0bb6c922f1c2742440f964ce6801 (patch)
treefb29f3273e7626bba610332461bfef7bc303a1e0 /Lib/zipfile.py
parentf458a036178844beae8bc332e5b5a0570276be3c (diff)
downloadcpython-e5e64444979f0bb6c922f1c2742440f964ce6801.zip
cpython-e5e64444979f0bb6c922f1c2742440f964ce6801.tar.gz
cpython-e5e64444979f0bb6c922f1c2742440f964ce6801.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 0b5d3e8..b223b4a 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -1071,11 +1071,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)