mirror of
https://github.com/boostorg/build.git
synced 2026-02-16 13:22:11 +00:00
Corrected a bug in the Boost Build configuration.py test that was causing it to leave behind an invalid BOOST_BUILD_USER_CONFIG environment variable setting after it finishes running with a Python interpreter prior to version 2.6 (calling os.environ.pop() did not actually clear the environment variable in question).
[SVN r78915]
This commit is contained in:
@@ -82,16 +82,12 @@ ECHO test-index: $(test-index:E=(unknown)) ;
|
||||
self.__registerTestId(str(test_id))
|
||||
extra_args += " ---test-id---=%s" % test_id
|
||||
env_name = "BOOST_BUILD_USER_CONFIG"
|
||||
previous_env = os.environ.pop(env_name, None)
|
||||
if env is not None:
|
||||
os.environ[env_name] = env
|
||||
previous_env = os.environ.get(env_name)
|
||||
_env_set(env_name, env)
|
||||
try:
|
||||
self.__tester.run_build_system(extra_args, *args, **kwargs)
|
||||
finally:
|
||||
if previous_env is None:
|
||||
os.environ.pop(env_name, None)
|
||||
else:
|
||||
os.environ[env_name] = previous_env
|
||||
_env_set(env_name, previous_env)
|
||||
|
||||
def __registerTestId(self, test_id):
|
||||
if test_id in self.__test_ids:
|
||||
@@ -251,6 +247,33 @@ def _canSetEmptyEnvironmentVariable():
|
||||
return result
|
||||
|
||||
|
||||
def _env_del(name):
|
||||
"""
|
||||
Unsets the given environment variable if it is currently set.
|
||||
|
||||
Note that we can not use os.environ.pop() or os.environ.clear() here
|
||||
since prior to Python 2.6 these functions did not remove the actual
|
||||
environment variable by calling os.unsetenv().
|
||||
|
||||
""""
|
||||
try:
|
||||
del os.environ[name]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
|
||||
def _env_set(name, value):
|
||||
"""
|
||||
Sets the given environment variable value or unsets it, if the value is
|
||||
None.
|
||||
|
||||
"""
|
||||
if value is None:
|
||||
_env_del(name)
|
||||
else:
|
||||
os.environ[name] = value
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# main()
|
||||
|
||||
Reference in New Issue
Block a user