Skip to content

bpo-42745: finalize_interp_types() calls _PyType_Fini() #23953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ void
_PyType_Fini(PyThreadState *tstate)
{
_PyType_ClearCache(&tstate->interp->type_cache);
clear_slotdefs();
if (_Py_IsMainInterpreter(tstate)) {
clear_slotdefs();
}
}


Expand Down
7 changes: 3 additions & 4 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2359,10 +2359,9 @@ _PyUnicode_FromId(_Py_Identifier *id)


static void
unicode_clear_identifiers(PyThreadState *tstate)
unicode_clear_identifiers(struct _Py_unicode_state *state)
{
PyInterpreterState *interp = _PyInterpreterState_GET();
struct _Py_unicode_ids *ids = &interp->unicode.ids;
struct _Py_unicode_ids *ids = &state->ids;
for (Py_ssize_t i=0; i < ids->size; i++) {
Py_XDECREF(ids->array[i]);
}
Expand Down Expand Up @@ -16243,7 +16242,7 @@ _PyUnicode_Fini(PyThreadState *tstate)

_PyUnicode_FiniEncodings(&state->fs_codec);

unicode_clear_identifiers(tstate);
unicode_clear_identifiers(state);

for (Py_ssize_t i = 0; i < 256; i++) {
Py_CLEAR(state->latin1[i]);
Expand Down
4 changes: 1 addition & 3 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,7 @@ finalize_interp_types(PyThreadState *tstate)
_PyFrame_Fini(tstate);
_PyAsyncGen_Fini(tstate);
_PyContext_Fini(tstate);
_PyType_Fini(tstate);
// Call _PyUnicode_ClearInterned() before _PyDict_Fini() since it uses
// a dict internally.
_PyUnicode_ClearInterned(tstate);
Expand Down Expand Up @@ -1751,9 +1752,6 @@ Py_FinalizeEx(void)
/* Destroy the database used by _PyImport_{Fixup,Find}Extension */
_PyImport_Fini();

/* Cleanup typeobject.c's internal caches. */
_PyType_Fini(tstate);

/* unload faulthandler module */
_PyFaulthandler_Fini();

Expand Down