From ca776b130d970c5cc372d5c01099ccf2a43254d3 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Mon, 20 Mar 2023 14:23:54 -0600 Subject: [PATCH] Make objects stored in global containers immortal. --- Python/pystate.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Python/pystate.c b/Python/pystate.c index 394b12d24065f21..f82a51d1f6eee4c 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -677,7 +677,11 @@ _Py_AddToGlobalDict(PyObject *dict, PyObject *key, PyObject *value) release_global_objects_lock(runtime); - // XXX Immortalize the key and value. + /* Immortalize the key and value. */ + _Py_SetImmortal(key); + if (value != key) { + _Py_SetImmortal(value); + } return actual; }