Fix the test for issue #6972.

Remove trailing dots on Windows.
This commit is contained in:
Serhiy Storchaka 2013-02-02 19:51:37 +02:00
commit 672671da47
2 changed files with 21 additions and 6 deletions

View file

@ -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)