diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2012-05-18 15:03:48 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2012-05-18 15:03:48 -0400 |
commit | f568de0c10f5d67ef9a91b8609997dbdf4ecce3d (patch) | |
tree | acb17dabc8cf9c3ba2c2d196f6339216c9c61fea /setuptools | |
parent | 5be712ee48b86f32284e72c3b862002fd3dedd85 (diff) | |
download | external_python_setuptools-f568de0c10f5d67ef9a91b8609997dbdf4ecce3d.tar.gz external_python_setuptools-f568de0c10f5d67ef9a91b8609997dbdf4ecce3d.tar.bz2 external_python_setuptools-f568de0c10f5d67ef9a91b8609997dbdf4ecce3d.zip |
Exclude 'encodings' modules when removing modules from sys.modules. Workaround for #285. (Fixes #285)
--HG--
branch : distribute
extra : rebase_source : 913eaebbb0971a044d6087dc4faa2fdb4220def2
Diffstat (limited to 'setuptools')
-rwxr-xr-x | setuptools/sandbox.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py index 8e0c09b5..ab2543d9 100755 --- a/setuptools/sandbox.py +++ b/setuptools/sandbox.py @@ -39,8 +39,14 @@ def run_setup(setup_script, args): finally: pkg_resources.__setstate__(pr_state) sys.modules.update(save_modules) - for key in list(sys.modules): - if key not in save_modules: del sys.modules[key] + # remove any modules imported within the sandbox + del_modules = [ + mod_name for mod_name in sys.modules + if mod_name not in save_modules + # exclude any encodings modules. See #285 + and not mod_name.startswith('encodings.') + ] + map(sys.modules.__delitem__, del_modules) os.chdir(old_dir) sys.path[:] = save_path sys.argv[:] = save_argv |