[Python-checkins] cpython (merge 3.3 -> default): Merge fix for #17731 from 3.3

nick.coghlan python-checkins at python.org
Mon Apr 15 14:58:09 CEST 2013


http://hg.python.org/cpython/rev/5d4001e32a31
changeset:   83391:5d4001e32a31
parent:      83389:193e7ad92900
parent:      83390:73c79022977b
user:        Nick Coghlan <ncoghlan at gmail.com>
date:        Mon Apr 15 22:57:57 2013 +1000
summary:
  Merge fix for #17731 from 3.3

files:
  Lib/test/test_import.py |  3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -43,6 +43,7 @@
     # sets up a temporary directory and removes it
     # creates the module file
     # temporarily clears the module from sys.modules (if any)
+    # reverts or removes the module when cleaning up
     name = name or "spam"
     with script_helper.temp_dir() as tempdir:
         path = script_helper.make_script(tempdir, name, source)
@@ -54,6 +55,8 @@
         finally:
             if old_module is not None:
                 sys.modules[name] = old_module
+            elif name in sys.modules:
+                del sys.modules[name]
 
 
 class ImportTests(unittest.TestCase):

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list