summaryrefslogtreecommitdiffstats
path: root/Lib/runpy.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2013-06-15 18:27:21 (GMT)
committerBrett Cannon <brett@python.org>2013-06-15 18:27:21 (GMT)
commit82d2107668c5e8ba803673b3ec4d35f21decd3fd (patch)
tree8c2f24d9aeeea116ceb1b02554ed1b101e2e52f8 /Lib/runpy.py
parentf4ba4ec1604fe84a9665d4de0767943f58417f24 (diff)
downloadcpython-82d2107668c5e8ba803673b3ec4d35f21decd3fd.zip
cpython-82d2107668c5e8ba803673b3ec4d35f21decd3fd.tar.gz
cpython-82d2107668c5e8ba803673b3ec4d35f21decd3fd.tar.bz2
Issue #17177: switch from imp.new_module to types.ModuleType for runpy
Diffstat (limited to 'Lib/runpy.py')
-rw-r--r--Lib/runpy.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/runpy.py b/Lib/runpy.py
index 39c0e9f..6d0954f 100644
--- a/Lib/runpy.py
+++ b/Lib/runpy.py
@@ -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):