(original) (raw)
changeset: 84149:8fff5554125d user: Brett Cannon brett@python.org date: Sat Jun 15 14:27:21 2013 -0400 files: Lib/runpy.py description: Issue #17177: switch from imp.new_module to types.ModuleType for runpy diff -r 81cf3d6e6756 -r 8fff5554125d Lib/runpy.py --- a/Lib/runpy.py Sat Jun 15 14:25:04 2013 -0400 +++ b/Lib/runpy.py Sat Jun 15 14:27:21 2013 -0400 @@ -14,6 +14,7 @@ import sys import importlib.machinery # importlib first so we can test #15386 via -m import imp +import types from pkgutil import read_code, get_loader, get_importer __all__ = [ @@ -24,7 +25,7 @@ """Temporarily replace a module in sys.modules with an empty namespace""" def __init__(self, mod_name): self.mod_name = mod_name - self.module = imp.new_module(mod_name) + self.module = types.ModuleType(mod_name) self._saved_module = [] def __enter__(self): /brett@python.org