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

Skip to content

Commit a6e0b4f

Browse files
committed
merge #7639
2 parents 1a07f07 + 9bad3a9 commit a6e0b4f

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
@@ -173,10 +173,10 @@ def add_tables(db, module):
173173

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

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

286286
def make_short(self, file):
287+
oldfile = file
288+
file = file.replace('+', '_')
289+
file = ''.join(c for c in file if not c in ' "/\[]:;=,')
287290
parts = file.split(".")
288-
if len(parts)>1:
291+
if len(parts) > 1:
292+
prefix = "".join(parts[:-1]).upper()
289293
suffix = parts[-1].upper()
294+
if not prefix:
295+
prefix = suffix
296+
suffix = None
290297
else:
298+
prefix = file.upper()
291299
suffix = None
292-
prefix = parts[0].upper()
293-
if len(prefix) <= 8 and (not suffix or len(suffix)<=3):
300+
if len(parts) < 3 and len(prefix) <= 8 and file == oldfile and (
301+
not suffix or len(suffix) <= 3):
294302
if suffix:
295303
file = prefix+"."+suffix
296304
else:
297305
file = prefix
298-
assert file not in self.short_names
299306
else:
307+
file = None
308+
if file is None or file in self.short_names:
300309
prefix = prefix[:6]
301310
if suffix:
302311
suffix = suffix[:3]

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Core and Builtins
5353
Library
5454
-------
5555

56+
- Issue #7639: Fix short file name generation in bdist_msi
57+
5658
- Issue #11659: Fix ResourceWarning in test_subprocess introduced by #11459.
5759
Patch by Ben Hayden.
5860

0 commit comments

Comments
 (0)