diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2013-06-18 08:44:39 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2013-06-18 08:44:39 -0500 |
commit | fb8c7cf0abc9ce58b8a6f0621c0a9909fb9b8eff (patch) | |
tree | 95cae06260f49e011fc045000fc1531dbc0e0cf5 /setuptools/sandbox.py | |
parent | 32ba6930fa97bbeac9392cac3ed49aac87fd1018 (diff) | |
parent | db678072da41b75408680dab3e23c1b76573bf1d (diff) | |
download | external_python_setuptools-fb8c7cf0abc9ce58b8a6f0621c0a9909fb9b8eff.tar.gz external_python_setuptools-fb8c7cf0abc9ce58b8a6f0621c0a9909fb9b8eff.tar.bz2 external_python_setuptools-fb8c7cf0abc9ce58b8a6f0621c0a9909fb9b8eff.zip |
Merge with upstream
--HG--
branch : distribute
Diffstat (limited to 'setuptools/sandbox.py')
-rwxr-xr-x | setuptools/sandbox.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py index 41f1119b..c49d1cfe 100755 --- a/setuptools/sandbox.py +++ b/setuptools/sandbox.py @@ -42,8 +42,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 @@ -163,12 +169,12 @@ else: _EXCEPTIONS = [] try: - from win32com.client.gencache import GetGeneratePath - _EXCEPTIONS.append(GetGeneratePath()) - del GetGeneratePath + from win32com.client.gencache import GetGeneratePath + _EXCEPTIONS.append(GetGeneratePath()) + del GetGeneratePath except ImportError: - # it appears pywin32 is not installed, so no need to exclude. - pass + # it appears pywin32 is not installed, so no need to exclude. + pass class DirectorySandbox(AbstractSandbox): """Restrict operations to a single subdirectory - pseudo-chroot""" |