mirror of
https://github.com/python/cpython.git
synced 2025-08-19 00:00:48 +00:00
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.
This commit is contained in:
parent
530698235d
commit
93e9384402
2 changed files with 16 additions and 0 deletions
|
@ -187,6 +187,19 @@ def get_build_architecture():
|
||||||
j = string.find(sys.version, ")", i)
|
j = string.find(sys.version, ")", i)
|
||||||
return sys.version[i+len(prefix):j]
|
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) :
|
class MSVCCompiler (CCompiler) :
|
||||||
|
@ -270,6 +283,7 @@ class MSVCCompiler (CCompiler) :
|
||||||
self.__paths.append(p)
|
self.__paths.append(p)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
self.__paths = normalize_and_reduce_paths(self.__paths)
|
||||||
os.environ['path'] = string.join(self.__paths, ';')
|
os.environ['path'] = string.join(self.__paths, ';')
|
||||||
|
|
||||||
self.preprocess_options = None
|
self.preprocess_options = None
|
||||||
|
|
|
@ -219,6 +219,8 @@ Extension Modules
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Patch #1685563: remove (don't add) duplicate paths in distutils.MSVCCompiler.
|
||||||
|
|
||||||
- Bug #978833: Revert r50844, as it broke _socketobject.dup.
|
- Bug #978833: Revert r50844, as it broke _socketobject.dup.
|
||||||
|
|
||||||
- Bug #1675967: re patterns pickled with Python 2.4 and earlier can
|
- Bug #1675967: re patterns pickled with Python 2.4 and earlier can
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue