Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9bad3a9

Browse files
committed
Fix short file name generation in bdist_msi.
Patch by Christoph Gohlke. Closes #7639.
1 parent c01ffdf commit 9bad3a9

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

Lib/msilib/__init__.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ def add_tables(db, module):
174174

175175
def make_id(str):
176176
#str = str.replace(".", "_") # colons are allowed
177-
str = str.replace(" ", "_")
178-
str = str.replace("-", "_")
179-
if str[0] in string.digits:
180-
str = "_"+str
177+
for c in " -+~;":
178+
str = str.replace(c, "_")
179+
if str[0] in (string.digits + "."):
180+
str = "_" + str
181181
assert re.match("^[A-Za-z_][A-Za-z0-9_.]*$", str), "FILE"+str
182182
return str
183183

@@ -285,19 +285,28 @@ def start_component(self, component = None, feature = None, flags = None, keyfil
285285
[(feature.id, component)])
286286

287287
def make_short(self, file):
288+
oldfile = file
289+
file = file.replace('+', '_')
290+
file = ''.join(c for c in file if not c in ' "/\[]:;=,')
288291
parts = file.split(".")
289-
if len(parts)>1:
292+
if len(parts) > 1:
293+
prefix = "".join(parts[:-1]).upper()
290294
suffix = parts[-1].upper()
295+
if not prefix:
296+
prefix = suffix
297+
suffix = None
291298
else:
299+
prefix = file.upper()
292300
suffix = None
293-
prefix = parts[0].upper()
294-
if len(prefix) <= 8 and (not suffix or len(suffix)<=3):
301+
if len(parts) < 3 and len(prefix) <= 8 and file == oldfile and (
302+
not suffix or len(suffix) <= 3):
295303
if suffix:
296304
file = prefix+"."+suffix
297305
else:
298306
file = prefix
299-
assert file not in self.short_names
300307
else:
308+
file = None
309+
if file is None or file in self.short_names:
301310
prefix = prefix[:6]
302311
if suffix:
303312
suffix = suffix[:3]

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Core and Builtins
4848
Library
4949
-------
5050

51+
- Issue #7639: Fix short file name generation in bdist_msi.
52+
5153
- Issue #11659: Fix ResourceWarning in test_subprocess introduced by #11459.
5254
Patch by Ben Hayden.
5355

0 commit comments

Comments
 (0)