Skip to content

Commit 16638a4

Browse files
authored
bpo-45654: No need to freeze types (GH-30028)
1 parent 3f398a7 commit 16638a4

File tree

7 files changed

+5
-27
lines changed

7 files changed

+5
-27
lines changed

Lib/runpy.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@
1414
import importlib.machinery # importlib first so we can test #15386 via -m
1515
import importlib.util
1616
import io
17-
import types
1817
import os
1918

2019
__all__ = [
2120
"run_module", "run_path",
2221
]
2322

23+
# avoid 'import types' just for ModuleType
24+
ModuleType = type(sys)
25+
2426
class _TempModule(object):
2527
"""Temporarily replace a module in sys.modules with an empty namespace"""
2628
def __init__(self, mod_name):
2729
self.mod_name = mod_name
28-
self.module = types.ModuleType(mod_name)
30+
self.module = ModuleType(mod_name)
2931
self._saved_module = []
3032

3133
def __enter__(self):

Makefile.pre.in

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@ DEEPFREEZE_OBJS = \
490490
Python/deepfreeze/os.o \
491491
Python/deepfreeze/site.o \
492492
Python/deepfreeze/stat.o \
493-
Python/deepfreeze/types.o \
494493
Python/deepfreeze/importlib.util.o \
495494
Python/deepfreeze/importlib.machinery.o \
496495
Python/deepfreeze/runpy.o \
@@ -1014,9 +1013,6 @@ Python/deepfreeze/site.c: Python/frozen_modules/site.h $(DEEPFREEZE_DEPS)
10141013
Python/deepfreeze/stat.c: Python/frozen_modules/stat.h $(DEEPFREEZE_DEPS)
10151014
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/stat.h -m stat -o Python/deepfreeze/stat.c
10161015

1017-
Python/deepfreeze/types.c: Python/frozen_modules/types.h $(DEEPFREEZE_DEPS)
1018-
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/types.h -m types -o Python/deepfreeze/types.c
1019-
10201016
Python/deepfreeze/importlib.util.c: Python/frozen_modules/importlib.util.h $(DEEPFREEZE_DEPS)
10211017
$(PYTHON_FOR_FREEZE) $(srcdir)/Tools/scripts/deepfreeze.py Python/frozen_modules/importlib.util.h -m importlib.util -o Python/deepfreeze/importlib.util.c
10221018

@@ -1065,7 +1061,6 @@ FROZEN_FILES_IN = \
10651061
Lib/os.py \
10661062
Lib/site.py \
10671063
Lib/stat.py \
1068-
Lib/types.py \
10691064
Lib/importlib/util.py \
10701065
Lib/importlib/machinery.py \
10711066
Lib/runpy.py \
@@ -1091,7 +1086,6 @@ FROZEN_FILES_OUT = \
10911086
Python/frozen_modules/os.h \
10921087
Python/frozen_modules/site.h \
10931088
Python/frozen_modules/stat.h \
1094-
Python/frozen_modules/types.h \
10951089
Python/frozen_modules/importlib.util.h \
10961090
Python/frozen_modules/importlib.machinery.h \
10971091
Python/frozen_modules/runpy.h \
@@ -1154,9 +1148,6 @@ Python/frozen_modules/site.h: $(FREEZE_MODULE) Lib/site.py
11541148
Python/frozen_modules/stat.h: $(FREEZE_MODULE) Lib/stat.py
11551149
$(FREEZE_MODULE) stat $(srcdir)/Lib/stat.py Python/frozen_modules/stat.h
11561150

1157-
Python/frozen_modules/types.h: $(FREEZE_MODULE) Lib/types.py
1158-
$(FREEZE_MODULE) types $(srcdir)/Lib/types.py Python/frozen_modules/types.h
1159-
11601151
Python/frozen_modules/importlib.util.h: $(FREEZE_MODULE) Lib/importlib/util.py
11611152
$(FREEZE_MODULE) importlib.util $(srcdir)/Lib/importlib/util.py Python/frozen_modules/importlib.util.h
11621153

PCbuild/_freeze_module.vcxproj

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,6 @@
332332
<DeepIntFile>$(IntDir)stat.g.c</DeepIntFile>
333333
<DeepOutFile>$(PySourcePath)Python\deepfreeze\df.stat.c</DeepOutFile>
334334
</None>
335-
<None Include="..\Lib\types.py">
336-
<ModName>types</ModName>
337-
<IntFile>$(IntDir)types.g.h</IntFile>
338-
<OutFile>$(PySourcePath)Python\frozen_modules\types.h</OutFile>
339-
<DeepIntFile>$(IntDir)types.g.c</DeepIntFile>
340-
<DeepOutFile>$(PySourcePath)Python\deepfreeze\df.types.c</DeepOutFile>
341-
</None>
342335
<None Include="..\Lib\importlib\util.py">
343336
<ModName>importlib.util</ModName>
344337
<IntFile>$(IntDir)importlib.util.g.h</IntFile>

PCbuild/_freeze_module.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,6 @@
447447
<None Include="..\Lib\stat.py">
448448
<Filter>Python Files</Filter>
449449
</None>
450-
<None Include="..\Lib\types.py">
451-
<Filter>Python Files</Filter>
452-
</None>
453450
<None Include="..\Lib\importlib\util.py">
454451
<Filter>Python Files</Filter>
455452
</None>

PCbuild/pythoncore.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@
541541
<ClCompile Include="..\Python\deepfreeze\df.os.c" />
542542
<ClCompile Include="..\Python\deepfreeze\df.site.c" />
543543
<ClCompile Include="..\Python\deepfreeze\df.stat.c" />
544-
<ClCompile Include="..\Python\deepfreeze\df.types.c" />
545544
<ClCompile Include="..\Python\deepfreeze\df.importlib.util.c" />
546545
<ClCompile Include="..\Python\deepfreeze\df.importlib.machinery.c" />
547546
<ClCompile Include="..\Python\deepfreeze\df.runpy.c" />

Python/frozen.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
#include "frozen_modules/os.h"
5454
#include "frozen_modules/site.h"
5555
#include "frozen_modules/stat.h"
56-
#include "frozen_modules/types.h"
5756
#include "frozen_modules/importlib.util.h"
5857
#include "frozen_modules/importlib.machinery.h"
5958
#include "frozen_modules/runpy.h"
@@ -83,7 +82,6 @@ extern PyObject *_Py_get_posixpath_toplevel(void);
8382
extern PyObject *_Py_get_os_toplevel(void);
8483
extern PyObject *_Py_get_site_toplevel(void);
8584
extern PyObject *_Py_get_stat_toplevel(void);
86-
extern PyObject *_Py_get_types_toplevel(void);
8785
extern PyObject *_Py_get_importlib_util_toplevel(void);
8886
extern PyObject *_Py_get_importlib_machinery_toplevel(void);
8987
extern PyObject *_Py_get_runpy_toplevel(void);
@@ -126,7 +124,6 @@ static const struct _frozen stdlib_modules[] = {
126124
{"stat", _Py_M__stat, (int)sizeof(_Py_M__stat), GET_CODE(stat)},
127125

128126
/* runpy - run module with -m */
129-
{"types", _Py_M__types, (int)sizeof(_Py_M__types), GET_CODE(types)},
130127
{"importlib.util", _Py_M__importlib_util, (int)sizeof(_Py_M__importlib_util), GET_CODE(importlib_util)},
131128
{"importlib.machinery", _Py_M__importlib_machinery, (int)sizeof(_Py_M__importlib_machinery), GET_CODE(importlib_machinery)},
132129
{"runpy", _Py_M__runpy, (int)sizeof(_Py_M__runpy), GET_CODE(runpy)},

Tools/scripts/freeze_modules.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@
6969
'stat',
7070
]),
7171
('runpy - run module with -m', [
72-
"types",
7372
"importlib.util",
7473
"importlib.machinery",
75-
"runpy"
74+
"runpy",
7675
]),
7776
(TESTS_SECTION, [
7877
'__hello__',

0 commit comments

Comments
 (0)