mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Fix the test and remove trailing dots on Windows for issue #6972.
This commit is contained in:
parent
dc6dc4bc31
commit
13e56c73b7
2 changed files with 18 additions and 9 deletions
|
@ -1050,11 +1050,14 @@ class ZipFile(object):
|
|||
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 = string.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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue