Skip to content

Commit

Permalink
Merge pull request #11 from pfmoore/remove_unsetenv
Browse files Browse the repository at this point in the history
Replace use of os.unsetenv(...) with del os.environ[...]
  • Loading branch information
wickman committed Nov 21, 2014
2 parents 33d390f + 161a03d commit d3a3015
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pex/pex.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ def start_coverage(cls):

@classmethod
def clean_environment(cls, forking=False):
os.unsetenv('MACOSX_DEPLOYMENT_TARGET')
try:
del os.environ['MACOSX_DEPLOYMENT_TARGET']
except KeyError:
pass
if not forking:
for key in filter(lambda key: key.startswith('PEX_'), os.environ):
os.unsetenv(key)
del os.environ[key]

def __init__(self, pex=sys.argv[0], interpreter=None):
self._pex = pex
Expand Down Expand Up @@ -266,8 +269,8 @@ def execute(self, args=()):
@classmethod
def execute_interpreter(cls):
force_interpreter = 'PEX_INTERPRETER' in os.environ
# TODO(wickman) Apparently os.unsetenv doesn't work on Windows
os.unsetenv('PEX_INTERPRETER')
if force_interpreter:
del os.environ['PEX_INTERPRETER']
TRACER.log('%s, dropping into interpreter' % (
'PEX_INTERPRETER specified' if force_interpreter else 'No entry point specified'))
if sys.argv[1:]:
Expand Down

0 comments on commit d3a3015

Please sign in to comment.