summaryrefslogtreecommitdiffstats
path: root/Lib/runpy.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2021-12-10 18:09:09 (GMT)
committerGitHub <noreply@github.com>2021-12-10 18:09:09 (GMT)
commit16638a4bdb802ae52d386a39d2dbef14de3fbc92 (patch)
tree2e1182e7d23fc5c59327fc9b4cd938fd491b49b2 /Lib/runpy.py
parent3f398a77d37b5dfd51dabbc362d482a482fa885a (diff)
downloadcpython-16638a4bdb802ae52d386a39d2dbef14de3fbc92.zip
cpython-16638a4bdb802ae52d386a39d2dbef14de3fbc92.tar.gz
cpython-16638a4bdb802ae52d386a39d2dbef14de3fbc92.tar.bz2
bpo-45654: No need to freeze types (GH-30028)
Diffstat (limited to 'Lib/runpy.py')
-rw-r--r--Lib/runpy.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/runpy.py b/Lib/runpy.py
index caba121..949fd59 100644
--- a/Lib/runpy.py
+++ b/Lib/runpy.py
@@ -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):