summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2023-09-08 09:34:40 (GMT)
committerGitHub <noreply@github.com>2023-09-08 09:34:40 (GMT)
commit15d4c9fabce67b8a1b5bd9dec9612014ec18291a (patch)
tree1c728c98663c224ec93022b0bdd0dd685c9fdf38 /Python
parent00cf626cd41f806062c22a913b647b4efa84c476 (diff)
downloadcpython-15d4c9fabce67b8a1b5bd9dec9612014ec18291a.zip
cpython-15d4c9fabce67b8a1b5bd9dec9612014ec18291a.tar.gz
cpython-15d4c9fabce67b8a1b5bd9dec9612014ec18291a.tar.bz2
GH-108716: Turn off deep-freezing of code objects. (GH-108722)
Diffstat (limited to 'Python')
-rw-r--r--Python/frozen.c58
-rw-r--r--Python/import.c13
-rw-r--r--Python/pylifecycle.c6
-rw-r--r--Python/pystate.c1
4 files changed, 31 insertions, 47 deletions
diff --git a/Python/frozen.c b/Python/frozen.c
index 6b97771..0fb38a1 100644
--- a/Python/frozen.c
+++ b/Python/frozen.c
@@ -101,46 +101,46 @@ extern PyObject *_Py_get_frozen_only_toplevel(void);
/* End extern declarations */
static const struct _frozen bootstrap_modules[] = {
- {"_frozen_importlib", _Py_M__importlib__bootstrap, (int)sizeof(_Py_M__importlib__bootstrap), false, GET_CODE(importlib__bootstrap)},
- {"_frozen_importlib_external", _Py_M__importlib__bootstrap_external, (int)sizeof(_Py_M__importlib__bootstrap_external), false, GET_CODE(importlib__bootstrap_external)},
- {"zipimport", _Py_M__zipimport, (int)sizeof(_Py_M__zipimport), false, GET_CODE(zipimport)},
+ {"_frozen_importlib", _Py_M__importlib__bootstrap, (int)sizeof(_Py_M__importlib__bootstrap), false},
+ {"_frozen_importlib_external", _Py_M__importlib__bootstrap_external, (int)sizeof(_Py_M__importlib__bootstrap_external), false},
+ {"zipimport", _Py_M__zipimport, (int)sizeof(_Py_M__zipimport), false},
{0, 0, 0} /* bootstrap sentinel */
};
static const struct _frozen stdlib_modules[] = {
/* stdlib - startup, without site (python -S) */
- {"abc", _Py_M__abc, (int)sizeof(_Py_M__abc), false, GET_CODE(abc)},
- {"codecs", _Py_M__codecs, (int)sizeof(_Py_M__codecs), false, GET_CODE(codecs)},
- {"io", _Py_M__io, (int)sizeof(_Py_M__io), false, GET_CODE(io)},
+ {"abc", _Py_M__abc, (int)sizeof(_Py_M__abc), false},
+ {"codecs", _Py_M__codecs, (int)sizeof(_Py_M__codecs), false},
+ {"io", _Py_M__io, (int)sizeof(_Py_M__io), false},
/* stdlib - startup, with site */
- {"_collections_abc", _Py_M___collections_abc, (int)sizeof(_Py_M___collections_abc), false, GET_CODE(_collections_abc)},
- {"_sitebuiltins", _Py_M___sitebuiltins, (int)sizeof(_Py_M___sitebuiltins), false, GET_CODE(_sitebuiltins)},
- {"genericpath", _Py_M__genericpath, (int)sizeof(_Py_M__genericpath), false, GET_CODE(genericpath)},
- {"ntpath", _Py_M__ntpath, (int)sizeof(_Py_M__ntpath), false, GET_CODE(ntpath)},
- {"posixpath", _Py_M__posixpath, (int)sizeof(_Py_M__posixpath), false, GET_CODE(posixpath)},
- {"os.path", _Py_M__posixpath, (int)sizeof(_Py_M__posixpath), false, GET_CODE(posixpath)},
- {"os", _Py_M__os, (int)sizeof(_Py_M__os), false, GET_CODE(os)},
- {"site", _Py_M__site, (int)sizeof(_Py_M__site), false, GET_CODE(site)},
- {"stat", _Py_M__stat, (int)sizeof(_Py_M__stat), false, GET_CODE(stat)},
+ {"_collections_abc", _Py_M___collections_abc, (int)sizeof(_Py_M___collections_abc), false},
+ {"_sitebuiltins", _Py_M___sitebuiltins, (int)sizeof(_Py_M___sitebuiltins), false},
+ {"genericpath", _Py_M__genericpath, (int)sizeof(_Py_M__genericpath), false},
+ {"ntpath", _Py_M__ntpath, (int)sizeof(_Py_M__ntpath), false},
+ {"posixpath", _Py_M__posixpath, (int)sizeof(_Py_M__posixpath), false},
+ {"os.path", _Py_M__posixpath, (int)sizeof(_Py_M__posixpath), false},
+ {"os", _Py_M__os, (int)sizeof(_Py_M__os), false},
+ {"site", _Py_M__site, (int)sizeof(_Py_M__site), false},
+ {"stat", _Py_M__stat, (int)sizeof(_Py_M__stat), false},
/* runpy - run module with -m */
- {"importlib.util", _Py_M__importlib_util, (int)sizeof(_Py_M__importlib_util), false, GET_CODE(importlib_util)},
- {"importlib.machinery", _Py_M__importlib_machinery, (int)sizeof(_Py_M__importlib_machinery), false, GET_CODE(importlib_machinery)},
- {"runpy", _Py_M__runpy, (int)sizeof(_Py_M__runpy), false, GET_CODE(runpy)},
+ {"importlib.util", _Py_M__importlib_util, (int)sizeof(_Py_M__importlib_util), false},
+ {"importlib.machinery", _Py_M__importlib_machinery, (int)sizeof(_Py_M__importlib_machinery), false},
+ {"runpy", _Py_M__runpy, (int)sizeof(_Py_M__runpy), false},
{0, 0, 0} /* stdlib sentinel */
};
static const struct _frozen test_modules[] = {
- {"__hello__", _Py_M____hello__, (int)sizeof(_Py_M____hello__), false, GET_CODE(__hello__)},
- {"__hello_alias__", _Py_M____hello__, (int)sizeof(_Py_M____hello__), false, GET_CODE(__hello__)},
- {"__phello_alias__", _Py_M____hello__, (int)sizeof(_Py_M____hello__), true, GET_CODE(__hello__)},
- {"__phello_alias__.spam", _Py_M____hello__, (int)sizeof(_Py_M____hello__), false, GET_CODE(__hello__)},
- {"__phello__", _Py_M____phello__, (int)sizeof(_Py_M____phello__), true, GET_CODE(__phello__)},
- {"__phello__.__init__", _Py_M____phello__, (int)sizeof(_Py_M____phello__), false, GET_CODE(__phello__)},
- {"__phello__.ham", _Py_M____phello___ham, (int)sizeof(_Py_M____phello___ham), true, GET_CODE(__phello___ham)},
- {"__phello__.ham.__init__", _Py_M____phello___ham, (int)sizeof(_Py_M____phello___ham), false, GET_CODE(__phello___ham)},
- {"__phello__.ham.eggs", _Py_M____phello___ham_eggs, (int)sizeof(_Py_M____phello___ham_eggs), false, GET_CODE(__phello___ham_eggs)},
- {"__phello__.spam", _Py_M____phello___spam, (int)sizeof(_Py_M____phello___spam), false, GET_CODE(__phello___spam)},
- {"__hello_only__", _Py_M__frozen_only, (int)sizeof(_Py_M__frozen_only), false, GET_CODE(frozen_only)},
+ {"__hello__", _Py_M____hello__, (int)sizeof(_Py_M____hello__), false},
+ {"__hello_alias__", _Py_M____hello__, (int)sizeof(_Py_M____hello__), false},
+ {"__phello_alias__", _Py_M____hello__, (int)sizeof(_Py_M____hello__), true},
+ {"__phello_alias__.spam", _Py_M____hello__, (int)sizeof(_Py_M____hello__), false},
+ {"__phello__", _Py_M____phello__, (int)sizeof(_Py_M____phello__), true},
+ {"__phello__.__init__", _Py_M____phello__, (int)sizeof(_Py_M____phello__), false},
+ {"__phello__.ham", _Py_M____phello___ham, (int)sizeof(_Py_M____phello___ham), true},
+ {"__phello__.ham.__init__", _Py_M____phello___ham, (int)sizeof(_Py_M____phello___ham), false},
+ {"__phello__.ham.eggs", _Py_M____phello___ham_eggs, (int)sizeof(_Py_M____phello___ham_eggs), false},
+ {"__phello__.spam", _Py_M____phello___spam, (int)sizeof(_Py_M____phello___spam), false},
+ {"__hello_only__", _Py_M__frozen_only, (int)sizeof(_Py_M__frozen_only), false},
{0, 0, 0} /* test sentinel */
};
const struct _frozen *_PyImport_FrozenBootstrap = bootstrap_modules;
diff --git a/Python/import.c b/Python/import.c
index 48090d0..126eb5e 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -2006,7 +2006,6 @@ look_up_frozen(const char *name)
struct frozen_info {
PyObject *nameobj;
const char *data;
- PyObject *(*get_code)(void);
Py_ssize_t size;
bool is_package;
bool is_alias;
@@ -2040,7 +2039,6 @@ find_frozen(PyObject *nameobj, struct frozen_info *info)
if (info != NULL) {
info->nameobj = nameobj; // borrowed
info->data = (const char *)p->code;
- info->get_code = p->get_code;
info->size = p->size;
info->is_package = p->is_package;
if (p->size < 0) {
@@ -2052,10 +2050,6 @@ find_frozen(PyObject *nameobj, struct frozen_info *info)
info->is_alias = resolve_module_alias(name, _PyImport_FrozenAliases,
&info->origname);
}
- if (p->code == NULL && p->size == 0 && p->get_code != NULL) {
- /* It is only deepfrozen. */
- return FROZEN_OKAY;
- }
if (p->code == NULL) {
/* It is frozen but marked as un-importable. */
return FROZEN_EXCLUDED;
@@ -2070,11 +2064,6 @@ find_frozen(PyObject *nameobj, struct frozen_info *info)
static PyObject *
unmarshal_frozen_code(PyInterpreterState *interp, struct frozen_info *info)
{
- if (info->get_code && _Py_IsMainInterpreter(interp)) {
- PyObject *code = info->get_code();
- assert(code != NULL);
- return code;
- }
PyObject *co = PyMarshal_ReadObjectFromString(info->data, info->size);
if (co == NULL) {
/* Does not contain executable code. */
@@ -3567,7 +3556,7 @@ _imp_get_frozen_object_impl(PyObject *module, PyObject *name,
if (info.nameobj == NULL) {
info.nameobj = name;
}
- if (info.size == 0 && info.get_code == NULL) {
+ if (info.size == 0) {
/* Does not contain executable code. */
set_frozen_error(FROZEN_INVALID, name);
return NULL;
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 92eef6d..4800015 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -832,11 +832,6 @@ pycore_interp_init(PyThreadState *tstate)
if (_PyStatus_EXCEPTION(status)) {
return status;
}
- // Intern strings in deep-frozen modules first so that others
- // can use it instead of creating a heap allocated string.
- if (_Py_Deepfreeze_Init() < 0) {
- return _PyStatus_ERR("failed to initialize deep-frozen modules");
- }
status = pycore_init_types(interp);
if (_PyStatus_EXCEPTION(status)) {
@@ -1743,7 +1738,6 @@ finalize_interp_clear(PyThreadState *tstate)
_Py_HashRandomization_Fini();
_PyArg_Fini();
_Py_ClearFileSystemEncoding();
- _Py_Deepfreeze_Fini();
_PyPerfTrampoline_Fini();
}
diff --git a/Python/pystate.c b/Python/pystate.c
index b2b9b9f..ed14f82 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -697,6 +697,7 @@ init_interpreter(PyInterpreterState *interp,
interp->optimizer = &_PyOptimizer_Default;
interp->optimizer_backedge_threshold = _PyOptimizer_Default.backedge_threshold;
interp->optimizer_resume_threshold = _PyOptimizer_Default.backedge_threshold;
+ interp->next_func_version = 1;
if (interp != &runtime->_main_interpreter) {
/* Fix the self-referential, statically initialized fields. */
interp->dtoa = (struct _dtoa_state)_dtoa_state_INIT(interp);