mirror of https://github.com/python/cpython
Merge fix for #17731 from 3.3
This commit is contained in:
commit
d25e7de4a1
|
@ -43,6 +43,7 @@ def _ready_to_import(name=None, source=""):
|
|||
# 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 @@ def _ready_to_import(name=None, source=""):
|
|||
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):
|
||||
|
|
Loading…
Reference in New Issue