[Python-checkins] cpython (merge 3.2 -> default): merge #7639

martin.v.loewis python-checkins at python.org
Sun Mar 27 10:16:44 CEST 2011


http://hg.python.org/cpython/rev/a7e0a1dbfbb6
changeset:   69002:a7e0a1dbfbb6
parent:      68998:b44156fdc7f2
parent:      69001:c7d0fc181376
user:        Martin v. Löwis <martin at v.loewis.de>
date:        Sun Mar 27 10:15:57 2011 +0200
summary:
  merge #7639

files:
  Lib/msilib/__init__.py |  25 +++++++++++++++++--------
  Misc/NEWS              |   2 ++
  2 files changed, 19 insertions(+), 8 deletions(-)


diff --git a/Lib/msilib/__init__.py b/Lib/msilib/__init__.py
--- a/Lib/msilib/__init__.py
+++ b/Lib/msilib/__init__.py
@@ -173,10 +173,10 @@
 
 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
 
@@ -284,19 +284,28 @@
                         [(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]
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -91,6 +91,8 @@
 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.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list