From f568de0c10f5d67ef9a91b8609997dbdf4ecce3d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 18 May 2012 15:03:48 -0400 Subject: Exclude 'encodings' modules when removing modules from sys.modules. Workaround for #285. (Fixes #285) --HG-- branch : distribute extra : rebase_source : 913eaebbb0971a044d6087dc4faa2fdb4220def2 --- setuptools/sandbox.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'setuptools/sandbox.py') 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 -- cgit v1.2.1 From d847dbfeee2b2c85d7bc0a66813c33836a9850fa Mon Sep 17 00:00:00 2001 From: Erik Bray Date: Thu, 6 Sep 2012 15:51:09 -0400 Subject: Adds a fix for issue #318, including a regression test. This also fixes another test that was passing trivially due to *bug* in yet another test, ugh --HG-- branch : distribute extra : rebase_source : 476550766b7b756dced040ad4356b7685d6f062a --- setuptools/sandbox.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'setuptools/sandbox.py') diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py index ab2543d9..64f725e7 100755 --- a/setuptools/sandbox.py +++ b/setuptools/sandbox.py @@ -166,12 +166,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""" -- cgit v1.2.1