Skip to content

Commit fdb8a82

Browse files
committed
Exclude immortal objects when keeping overwritten locals alive
1 parent 32bd0c6 commit fdb8a82

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Objects/frameobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,15 @@ framelocalsproxy_setitem(PyObject *self, PyObject *key, PyObject *value)
244244
Py_XINCREF(value);
245245
PyCell_SetTakeRef((PyCellObject *)cell, value);
246246
} else if (value != PyStackRef_AsPyObjectBorrow(oldvalue)) {
247-
if (!PyStackRef_IsNull(fast[i])) {
247+
PyObject *old_obj = PyStackRef_AsPyObjectBorrow(fast[i]);
248+
if (old_obj != NULL && !_Py_IsImmortal(old_obj)) {
248249
if (frame->f_overwritten_fast_locals == NULL) {
249250
frame->f_overwritten_fast_locals = PyList_New(0);
250251
if (frame->f_overwritten_fast_locals == NULL) {
251252
return -1;
252253
}
253254
}
254-
PyObject *obj = PyStackRef_AsPyObjectBorrow(fast[i]);
255-
if (PyList_Append(frame->f_overwritten_fast_locals, obj) < 0) {
255+
if (PyList_Append(frame->f_overwritten_fast_locals, old_obj) < 0) {
256256
return -1;
257257
}
258258
PyStackRef_CLOSE(fast[i]);

0 commit comments

Comments
 (0)