From 16638a4bdb802ae52d386a39d2dbef14de3fbc92 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Fri, 10 Dec 2021 20:09:09 +0200 Subject: bpo-45654: No need to freeze types (GH-30028) --- Lib/runpy.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Lib/runpy.py') diff --git a/Lib/runpy.py b/Lib/runpy.py index caba121426..949fd5939b 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): -- cgit v1.2.1