bpo-45654: No need to freeze types (GH-30028)

This commit is contained in:
Christian Heimes 2021-12-10 20:09:09 +02:00 committed by GitHub
parent 3f398a77d3
commit 16638a4bdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 5 additions and 27 deletions

View file

@ -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):