summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2007-04-01 18:29:47 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2007-04-01 18:29:47 (GMT)
commit93e938440213c9e032b4c4e1af6bb20a1ce644a1 (patch)
tree1b9b04d614de81cd0cbb21ce2d965a7836cea3b2
parent530698235d8397346532a31dd50d5e39152d0c36 (diff)
downloadcpython-93e938440213c9e032b4c4e1af6bb20a1ce644a1.zip
cpython-93e938440213c9e032b4c4e1af6bb20a1ce644a1.tar.gz
cpython-93e938440213c9e032b4c4e1af6bb20a1ce644a1.tar.bz2
Backport 54644:
SF #1685563, MSVCCompiler creates redundant and long PATH strings If MSVCCompiler.initialize() was called multiple times, the path would get duplicated. On Windows, this is a problem because the path is limited to 4k. There's no benefit in adding a path multiple times, so prevent that from occuring. We also normalize the path before checking for duplicates so things like /a and /a/ won't both be stored.
-rw-r--r--Lib/distutils/msvccompiler.py14
-rw-r--r--Misc/NEWS2
2 files changed, 16 insertions, 0 deletions
diff --git a/Lib/distutils/msvccompiler.py b/Lib/distutils/msvccompiler.py
index 0d72837..29a9020 100644
--- a/Lib/distutils/msvccompiler.py
+++ b/Lib/distutils/msvccompiler.py
@@ -187,6 +187,19 @@ def get_build_architecture():
j = string.find(sys.version, ")", i)
return sys.version[i+len(prefix):j]
+def normalize_and_reduce_paths(paths):
+ """Return a list of normalized paths with duplicates removed.
+
+ The current order of paths is maintained.
+ """
+ # Paths are normalized so things like: /a and /a/ aren't both preserved.
+ reduced_paths = []
+ for p in paths:
+ np = os.path.normpath(p)
+ # XXX(nnorwitz): O(n**2), if reduced_paths gets long perhaps use a set.
+ if np not in reduced_paths:
+ reduced_paths.append(np)
+ return reduced_paths
class MSVCCompiler (CCompiler) :
@@ -270,6 +283,7 @@ class MSVCCompiler (CCompiler) :
self.__paths.append(p)
except KeyError:
pass
+ self.__paths = normalize_and_reduce_paths(self.__paths)
os.environ['path'] = string.join(self.__paths, ';')
self.preprocess_options = None
diff --git a/Misc/NEWS b/Misc/NEWS
index da35e71..c795b80 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -219,6 +219,8 @@ Extension Modules
Library
-------
+- Patch #1685563: remove (don't add) duplicate paths in distutils.MSVCCompiler.
+
- Bug #978833: Revert r50844, as it broke _socketobject.dup.
- Bug #1675967: re patterns pickled with Python 2.4 and earlier can