Skip to content

Commit 82d2107

Browse files
committed
Issue #17177: switch from imp.new_module to types.ModuleType for runpy
1 parent f4ba4ec commit 82d2107

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Lib/runpy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import sys
1515
import importlib.machinery # importlib first so we can test #15386 via -m
1616
import imp
17+
import types
1718
from pkgutil import read_code, get_loader, get_importer
1819

1920
__all__ = [
@@ -24,7 +25,7 @@ class _TempModule(object):
2425
"""Temporarily replace a module in sys.modules with an empty namespace"""
2526
def __init__(self, mod_name):
2627
self.mod_name = mod_name
27-
self.module = imp.new_module(mod_name)
28+
self.module = types.ModuleType(mod_name)
2829
self._saved_module = []
2930

3031
def __enter__(self):

0 commit comments

Comments
 (0)