[Python-checkins] cpython (merge 3.3 -> default): Do a better job of preserving the state of sys.modules.
barry.warsaw
python-checkins at python.org
Tue Nov 20 23:12:15 CET 2012
http://hg.python.org/cpython/rev/879c7b659fca
changeset: 80537:879c7b659fca
parent: 80534:10c1f9e05f4f
parent: 80536:4c5854ef7276
user: Barry Warsaw <barry at python.org>
date: Tue Nov 20 17:10:39 2012 -0500
summary:
Do a better job of preserving the state of sys.modules.
files:
Lib/test/test_importlib/import_/test_path.py | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/Lib/test/test_importlib/import_/test_path.py b/Lib/test/test_importlib/import_/test_path.py
--- a/Lib/test/test_importlib/import_/test_path.py
+++ b/Lib/test/test_importlib/import_/test_path.py
@@ -98,13 +98,18 @@
new_path_hooks = [zipimport.zipimporter,
_bootstrap.FileFinder.path_hook(
*_bootstrap._get_supported_file_loaders())]
- with util.uncache('email'):
+ missing = object()
+ email = sys.modules.pop('email', missing)
+ try:
with util.import_state(meta_path=sys.meta_path[:],
path=new_path,
path_importer_cache=new_path_importer_cache,
path_hooks=new_path_hooks):
module = import_module('email')
self.assertIsInstance(module, ModuleType)
+ finally:
+ if email is not missing:
+ sys.modules['email'] = email
def test_main():
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list