diff options
author | Christian Heimes <christian@python.org> | 2021-12-10 18:09:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-10 18:09:09 (GMT) |
commit | 16638a4bdb802ae52d386a39d2dbef14de3fbc92 (patch) | |
tree | 2e1182e7d23fc5c59327fc9b4cd938fd491b49b2 | |
parent | 3f398a77d37b5dfd51dabbc362d482a482fa885a (diff) | |
download | cpython-16638a4bdb802ae52d386a39d2dbef14de3fbc92.zip cpython-16638a4bdb802ae52d386a39d2dbef14de3fbc92.tar.gz cpython-16638a4bdb802ae52d386a39d2dbef14de3fbc92.tar.bz2 |
bpo-45654: No need to freeze types (GH-30028)
-rw-r--r-- | Lib/runpy.py | 6 | ||||
-rw-r--r-- | Makefile.pre.in | 9 | ||||
-rw-r--r-- | PCbuild/_freeze_module.vcxproj | 7 | ||||
-rw-r--r-- | PCbuild/_freeze_module.vcxproj.filters | 3 | ||||
-rw-r--r-- | PCbuild/pythoncore.vcxproj | 1 | ||||
-rw-r--r-- | Python/frozen.c | 3 | ||||
-rw-r--r-- | Tools/scripts/freeze_modules.py | 3 |
7 files changed, 5 insertions, 27 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): diff --git a/Makefile.pre.in b/Makefile.pre.in index 57928ee..a182786 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -490,7 +490,6 @@ DEEPFREEZE_OBJS = \ Python/deepfreeze/os.o \ Python/deepfreeze/site.o \ Python/deepfreeze/stat.o \ - Python/deepfreeze/types.o \ Python/deepfreeze/importlib.util.o \ Python/deepfreeze/importlib.machinery.o \ Python/deepfreeze/runpy.o \ @@ -1014,9 +1013,6 @@ Python/deepfreeze/site.c: Python/frozen_modules/site.h $(DEEPFREEZE_DEPS) Python/deepfreeze/stat.c: Python/frozen_modules/stat.h $(DEEPFREEZE_DEPS) $(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/stat.h -m stat -o Python/deepfreeze/stat.c -Python/deepfreeze/types.c: Python/frozen_modules/types.h $(DEEPFREEZE_DEPS) - $(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/types.h -m types -o Python/deepfreeze/types.c - Python/deepfreeze/importlib.util.c: Python/frozen_modules/importlib.util.h $(DEEPFREEZE_DEPS) $(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/importlib.util.h -m importlib.util -o Python/deepfreeze/importlib.util.c @@ -1065,7 +1061,6 @@ FROZEN_FILES_IN = \ Lib/os.py \ Lib/site.py \ Lib/stat.py \ - Lib/types.py \ Lib/importlib/util.py \ Lib/importlib/machinery.py \ Lib/runpy.py \ @@ -1091,7 +1086,6 @@ FROZEN_FILES_OUT = \ Python/frozen_modules/os.h \ Python/frozen_modules/site.h \ Python/frozen_modules/stat.h \ - Python/frozen_modules/types.h \ Python/frozen_modules/importlib.util.h \ Python/frozen_modules/importlib.machinery.h \ Python/frozen_modules/runpy.h \ @@ -1154,9 +1148,6 @@ Python/frozen_modules/site.h: $(FREEZE_MODULE) Lib/site.py Python/frozen_modules/stat.h: $(FREEZE_MODULE) Lib/stat.py $(FREEZE_MODULE) stat $(srcdir)/Lib/stat.py Python/frozen_modules/stat.h -Python/frozen_modules/types.h: $(FREEZE_MODULE) Lib/types.py - $(FREEZE_MODULE) types $(srcdir)/Lib/types.py Python/frozen_modules/types.h - Python/frozen_modules/importlib.util.h: $(FREEZE_MODULE) Lib/importlib/util.py $(FREEZE_MODULE) importlib.util $(srcdir)/Lib/importlib/util.py Python/frozen_modules/importlib.util.h diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj index 2beb425..11a6a87 100644 --- a/PCbuild/_freeze_module.vcxproj +++ b/PCbuild/_freeze_module.vcxproj @@ -332,13 +332,6 @@ <DeepIntFile>$(IntDir)stat.g.c</DeepIntFile> <DeepOutFile>$(PySourcePath)Python\deepfreeze\df.stat.c</DeepOutFile> </None> - <None Include="..\Lib\types.py"> - <ModName>types</ModName> - <IntFile>$(IntDir)types.g.h</IntFile> - <OutFile>$(PySourcePath)Python\frozen_modules\types.h</OutFile> - <DeepIntFile>$(IntDir)types.g.c</DeepIntFile> - <DeepOutFile>$(PySourcePath)Python\deepfreeze\df.types.c</DeepOutFile> - </None> <None Include="..\Lib\importlib\util.py"> <ModName>importlib.util</ModName> <IntFile>$(IntDir)importlib.util.g.h</IntFile> diff --git a/PCbuild/_freeze_module.vcxproj.filters b/PCbuild/_freeze_module.vcxproj.filters index 7690e5e..d107849 100644 --- a/PCbuild/_freeze_module.vcxproj.filters +++ b/PCbuild/_freeze_module.vcxproj.filters @@ -447,9 +447,6 @@ <None Include="..\Lib\stat.py"> <Filter>Python Files</Filter> </None> - <None Include="..\Lib\types.py"> - <Filter>Python Files</Filter> - </None> <None Include="..\Lib\importlib\util.py"> <Filter>Python Files</Filter> </None> diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 33abfaf..098cc21 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -541,7 +541,6 @@ <ClCompile Include="..\Python\deepfreeze\df.os.c" /> <ClCompile Include="..\Python\deepfreeze\df.site.c" /> <ClCompile Include="..\Python\deepfreeze\df.stat.c" /> - <ClCompile Include="..\Python\deepfreeze\df.types.c" /> <ClCompile Include="..\Python\deepfreeze\df.importlib.util.c" /> <ClCompile Include="..\Python\deepfreeze\df.importlib.machinery.c" /> <ClCompile Include="..\Python\deepfreeze\df.runpy.c" /> diff --git a/Python/frozen.c b/Python/frozen.c index 377c322..25cf0a8 100644 --- a/Python/frozen.c +++ b/Python/frozen.c @@ -53,7 +53,6 @@ #include "frozen_modules/os.h" #include "frozen_modules/site.h" #include "frozen_modules/stat.h" -#include "frozen_modules/types.h" #include "frozen_modules/importlib.util.h" #include "frozen_modules/importlib.machinery.h" #include "frozen_modules/runpy.h" @@ -83,7 +82,6 @@ extern PyObject *_Py_get_posixpath_toplevel(void); extern PyObject *_Py_get_os_toplevel(void); extern PyObject *_Py_get_site_toplevel(void); extern PyObject *_Py_get_stat_toplevel(void); -extern PyObject *_Py_get_types_toplevel(void); extern PyObject *_Py_get_importlib_util_toplevel(void); extern PyObject *_Py_get_importlib_machinery_toplevel(void); extern PyObject *_Py_get_runpy_toplevel(void); @@ -126,7 +124,6 @@ static const struct _frozen stdlib_modules[] = { {"stat", _Py_M__stat, (int)sizeof(_Py_M__stat), GET_CODE(stat)}, /* runpy - run module with -m */ - {"types", _Py_M__types, (int)sizeof(_Py_M__types), GET_CODE(types)}, {"importlib.util", _Py_M__importlib_util, (int)sizeof(_Py_M__importlib_util), GET_CODE(importlib_util)}, {"importlib.machinery", _Py_M__importlib_machinery, (int)sizeof(_Py_M__importlib_machinery), GET_CODE(importlib_machinery)}, {"runpy", _Py_M__runpy, (int)sizeof(_Py_M__runpy), GET_CODE(runpy)}, diff --git a/Tools/scripts/freeze_modules.py b/Tools/scripts/freeze_modules.py index b0c9531..58d1398 100644 --- a/Tools/scripts/freeze_modules.py +++ b/Tools/scripts/freeze_modules.py @@ -69,10 +69,9 @@ FROZEN = [ 'stat', ]), ('runpy - run module with -m', [ - "types", "importlib.util", "importlib.machinery", - "runpy" + "runpy", ]), (TESTS_SECTION, [ '__hello__', |