]> granicus.if.org Git - python/commitdiff
Fix short file name generation in bdist_msi.
authorMartin v. Löwis <martin@v.loewis.de>
Sun, 27 Mar 2011 08:12:07 +0000 (10:12 +0200)
committerMartin v. Löwis <martin@v.loewis.de>
Sun, 27 Mar 2011 08:12:07 +0000 (10:12 +0200)
Patch by Christoph Gohlke.
Closes #7639.

Lib/msilib/__init__.py
Misc/NEWS

index 114a1c788cbb2818a9e89677ef4369e3dfdbc241..ce4365fb69d7cea73ced5e96b67efc154492045d 100644 (file)
@@ -174,10 +174,10 @@ def add_tables(db, module):
 
 def make_id(str):
     #str = str.replace(".", "_") # colons are allowed
-    str = str.replace(" ", "_")
-    str = str.replace("-", "_")
-    if str[0] in string.digits:
-        str = "_"+str
+    for c in " -+~;":
+        str = str.replace(c, "_")
+    if str[0] in (string.digits + "."):
+        str = "_" + str
     assert re.match("^[A-Za-z_][A-Za-z0-9_.]*$", str), "FILE"+str
     return str
 
@@ -285,19 +285,28 @@ class Directory:
                         [(feature.id, component)])
 
     def make_short(self, file):
+        oldfile = file
+        file = file.replace('+', '_')
+        file = ''.join(c for c in file if not c in ' "/\[]:;=,')
         parts = file.split(".")
-        if len(parts)>1:
+        if len(parts) > 1:
+            prefix = "".join(parts[:-1]).upper()
             suffix = parts[-1].upper()
+            if not prefix:
+                prefix = suffix
+                suffix = None
         else:
+            prefix = file.upper()
             suffix = None
-        prefix = parts[0].upper()
-        if len(prefix) <= 8 and (not suffix or len(suffix)<=3):
+        if len(parts) < 3 and len(prefix) <= 8 and file == oldfile and (
+                                                not suffix or len(suffix) <= 3):
             if suffix:
                 file = prefix+"."+suffix
             else:
                 file = prefix
-            assert file not in self.short_names
         else:
+            file = None
+        if file is None or file in self.short_names:
             prefix = prefix[:6]
             if suffix:
                 suffix = suffix[:3]
index 936930b487a473c19de36913dfe7bc14a702e491..0ae694626cfbd9268fa9ddb4d3fe0c7de29e51f7 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -48,6 +48,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #7639: Fix short file name generation in bdist_msi.
+
 - Issue #11659: Fix ResourceWarning in test_subprocess introduced by #11459.
   Patch by Ben Hayden.