Kaydet (Commit) 82d21076 authored tarafından Brett Cannon's avatar Brett Cannon

Issue #17177: switch from imp.new_module to types.ModuleType for runpy

üst f4ba4ec1
...@@ -14,6 +14,7 @@ import os ...@@ -14,6 +14,7 @@ import os
import sys import sys
import importlib.machinery # importlib first so we can test #15386 via -m import importlib.machinery # importlib first so we can test #15386 via -m
import imp import imp
import types
from pkgutil import read_code, get_loader, get_importer from pkgutil import read_code, get_loader, get_importer
__all__ = [ __all__ = [
...@@ -24,7 +25,7 @@ class _TempModule(object): ...@@ -24,7 +25,7 @@ class _TempModule(object):
"""Temporarily replace a module in sys.modules with an empty namespace""" """Temporarily replace a module in sys.modules with an empty namespace"""
def __init__(self, mod_name): def __init__(self, mod_name):
self.mod_name = mod_name self.mod_name = mod_name
self.module = imp.new_module(mod_name) self.module = types.ModuleType(mod_name)
self._saved_module = [] self._saved_module = []
def __enter__(self): def __enter__(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment