[Python-checkins] cpython (3.3): Do a better job of preserving the state of sys.modules.
barry.warsaw
python-checkins at python.org
Tue Nov 20 23:12:13 CET 2012
http://hg.python.org/cpython/rev/4c5854ef7276
changeset: 80536:4c5854ef7276
branch: 3.3
parent: 80533:8b73a069ae4f
user: Barry Warsaw <barry at python.org>
date: Tue Nov 20 17:10:10 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