diff options
author | Victor Stinner <vstinner@python.org> | 2019-11-20 00:18:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-20 00:18:11 (GMT) |
commit | 444b39bb64aa894d3f1831210a8ce40042a5a532 (patch) | |
tree | 994677ebd6160f8107ddd052c18813a9e61288ba /Python | |
parent | e0cd8aa70a3ce19c3d3712568940aa0cbd9aa97b (diff) | |
download | cpython-444b39bb64aa894d3f1831210a8ce40042a5a532.zip cpython-444b39bb64aa894d3f1831210a8ce40042a5a532.tar.gz cpython-444b39bb64aa894d3f1831210a8ce40042a5a532.tar.bz2 |
bpo-38631: Avoid Py_FatalError() in handle_legacy_finalizers() (GH-17266)
* Rename _PyGC_Initialize() to _PyGC_InitializeRuntime()
* Add _PyGC_Init(): initialize _PyRuntime.gc.garbage list
* Call _PyGC_Init() before _PyTypes_Init()
Diffstat (limited to 'Python')
-rw-r--r-- | Python/pylifecycle.c | 15 | ||||
-rw-r--r-- | Python/pystate.c | 2 |
2 files changed, 12 insertions, 5 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 1bfc7c1..9739bb1 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -558,9 +558,16 @@ pycore_create_interpreter(_PyRuntimeState *runtime, static PyStatus -pycore_init_types(void) +pycore_init_types(_PyRuntimeState *runtime) { - PyStatus status = _PyTypes_Init(); + PyStatus status; + + status = _PyGC_Init(runtime); + if (_PyStatus_EXCEPTION(status)) { + return status; + } + + status = _PyTypes_Init(); if (_PyStatus_EXCEPTION(status)) { return status; } @@ -683,7 +690,7 @@ pyinit_config(_PyRuntimeState *runtime, config = &tstate->interp->config; *tstate_p = tstate; - status = pycore_init_types(); + status = pycore_init_types(runtime); if (_PyStatus_EXCEPTION(status)) { return status; } @@ -1447,7 +1454,7 @@ new_interpreter(PyThreadState **tstate_p) } config = &interp->config; - status = pycore_init_types(); + status = pycore_init_types(runtime); /* XXX The following is lax in error checking */ PyObject *modules = PyDict_New(); diff --git a/Python/pystate.c b/Python/pystate.c index b4b1247..06cc9a8 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -58,7 +58,7 @@ _PyRuntimeState_Init_impl(_PyRuntimeState *runtime) runtime->open_code_userdata = open_code_userdata; runtime->audit_hook_head = audit_hook_head; - _PyGC_Initialize(&runtime->gc); + _PyGC_InitializeRuntime(&runtime->gc); _PyEval_Initialize(&runtime->ceval); PyPreConfig_InitPythonConfig(&runtime->preconfig); |