Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c4d7d32

Browse files
Call drop_owned() after Py_EndInterpreter(), not before.
1 parent b93271d commit c4d7d32

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Modules/_xxsubinterpretersmodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,8 @@ add_owned(owned_ids *owned, PyInterpreterState *interp)
550550
}
551551

552552
static void
553-
drop_owned(owned_ids *owned, PyInterpreterState *interp)
553+
drop_owned(owned_ids *owned, int64_t interpid)
554554
{
555-
int64_t id = PyInterpreterState_GetID(interp);
556555
#if sizeof(int64_t) <= sizeof(Py_uhash_t)
557556
_Py_hashtable_steal(owned_ids, (const void *)id);
558557
#else
@@ -758,6 +757,7 @@ interp_destroy(PyObject *self, PyObject *args, PyObject *kwds)
758757
if (interp == NULL) {
759758
return NULL;
760759
}
760+
int64_t interpid = PyInterpreterState_GetID(interp);
761761

762762
// Ensure we don't try to destroy the current interpreter.
763763
PyInterpreterState *current = _get_current_interp();
@@ -778,11 +778,11 @@ interp_destroy(PyObject *self, PyObject *args, PyObject *kwds)
778778
return NULL;
779779
}
780780

781-
drop_owned(&_globals.owned, interp);
782-
783781
// Destroy the interpreter.
784782
_PyXI_EndInterpreter(interp, NULL, NULL);
785783

784+
drop_owned(&_globals.owned, interpid);
785+
786786
Py_RETURN_NONE;
787787
}
788788

0 commit comments

Comments
 (0)