]> granicus.if.org Git - python/commitdiff
Issue #17177: switch from imp.new_module to types.ModuleType for runpy
authorBrett Cannon <brett@python.org>
Sat, 15 Jun 2013 18:27:21 +0000 (14:27 -0400)
committerBrett Cannon <brett@python.org>
Sat, 15 Jun 2013 18:27:21 +0000 (14:27 -0400)
Lib/runpy.py

index 39c0e9f7dd31ad8eba08d4c5f979d9c9eeb42925..6d0954f147b07c009ee6d56944dbbf298888d989 100644 (file)
@@ -14,6 +14,7 @@ import os
 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 @@ class _TempModule(object):
     """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):