mirror of
https://github.com/python/cpython.git
synced 2025-10-06 23:21:06 +00:00
bpo-45654: No need to freeze types (GH-30028)
This commit is contained in:
parent
3f398a77d3
commit
16638a4bdb
7 changed files with 5 additions and 27 deletions
|
@ -14,18 +14,20 @@ import sys
|
|||
import importlib.machinery # importlib first so we can test #15386 via -m
|
||||
import importlib.util
|
||||
import io
|
||||
import types
|
||||
import os
|
||||
|
||||
__all__ = [
|
||||
"run_module", "run_path",
|
||||
]
|
||||
|
||||
# avoid 'import types' just for ModuleType
|
||||
ModuleType = type(sys)
|
||||
|
||||
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 = types.ModuleType(mod_name)
|
||||
self.module = ModuleType(mod_name)
|
||||
self._saved_module = []
|
||||
|
||||
def __enter__(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue