Skip to content

Commit b649a84

Browse files
Make objects stored in global containers immortal.
1 parent 22753b3 commit b649a84

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Python/pystate.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,14 @@ _Py_AddToGlobalDict(PyObject *dict, PyObject *key, PyObject *value)
677677

678678
release_global_objects_lock(runtime);
679679

680-
// XXX Immortalize the key and value.
680+
/* Immortalize the key and value. */
681+
if (actual == value) {
682+
/* It was added. */
683+
_Py_SetImmortal(key);
684+
if (value != key) {
685+
_Py_SetImmortal(value);
686+
}
687+
}
681688

682689
return actual;
683690
}

0 commit comments

Comments
 (0)