Skip to content

Commit d8976f1

Browse files
committed
Merged revisions 66171 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r66171 | amaury.forgeotdarc | 2008-09-03 01:19:56 +0200 (mer., 03 sept. 2008) | 9 lines Issue 2975: when compiling multiple extension modules with visual studio 2008 from the same python instance, some environment variables (LIB, INCLUDE) would grow without limit. Tested with these statements: distutils.ccompiler.new_compiler().initialize() print os.environ['LIB'] But I don't know how to turn them into reliable unit tests. ........
1 parent ebad7f0 commit d8976f1

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

Lib/distutils/msvc9compiler.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,17 @@ def normalize_and_reduce_paths(paths):
193193
reduced_paths.append(np)
194194
return reduced_paths
195195

196+
def removeDuplicates(variable):
197+
"""Remove duplicate values of an environment variable.
198+
"""
199+
oldList = variable.split(os.pathsep)
200+
newList = []
201+
for i in oldList:
202+
if i not in newList:
203+
newList.append(i)
204+
newVariable = os.pathsep.join(newList)
205+
return newVariable
206+
196207
def find_vcvarsall(version):
197208
"""Find the vcvarsall.bat file
198209
@@ -252,12 +263,12 @@ def query_vcvarsall(version, arch="x86"):
252263
if '=' not in line:
253264
continue
254265
line = line.strip()
255-
key, value = line.split('=')
266+
key, value = line.split('=', 1)
256267
key = key.lower()
257268
if key in interesting:
258269
if value.endswith(os.pathsep):
259270
value = value[:-1]
260-
result[key] = value
271+
result[key] = removeDuplicates(value)
261272

262273
if len(result) != len(interesting):
263274
raise ValueError(str(list(result.keys())))

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ Library
7474
Extension Modules
7575
-----------------
7676

77+
- Issue #2975: When compiling several extension modules with Visual Studio 2008
78+
from the same python interpreter, some environment variables would grow
79+
without limit.
80+
7781
- Issue #3643: Added a few more checks to _testcapi to prevent segfaults by
7882
exploitation of poor argument checking.
7983

0 commit comments

Comments
 (0)