Skip to content
Open
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
16 changes: 15 additions & 1 deletion Objects/codeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,8 +754,8 @@ _PyCode_New(struct _PyCodeConstructor *con)

#ifdef Py_GIL_DISABLED
co->_co_unique_id = _PyObject_AssignUniqueId((PyObject *)co);
#endif
_PyObject_GC_TRACK(co);
#endif
Py_XDECREF(replacement_locations);
return co;
}
Expand Down Expand Up @@ -2362,6 +2362,13 @@ code_new_impl(PyTypeObject *type, int argcount, int posonlyargcount,
linetable,
exceptiontable
);
#ifndef Py_GIL_DISABLED
// not tracked by default w/ GIL, but replace can create cycles
if (co) {
_PyObject_GC_TRACK(co);
}
#endif

cleanup:
Py_XDECREF(ournames);
Py_XDECREF(ourvarnames);
Expand Down Expand Up @@ -2827,6 +2834,13 @@ code_replace_impl(PyCodeObject *self, int co_argcount,
co_qualname, co_firstlineno,
co_linetable, co_exceptiontable);

#ifndef Py_GIL_DISABLED
// not tracked by default w/ GIL, but replace can create cycles
if (co) {
_PyObject_GC_TRACK(co);
}
#endif

error:
Py_XDECREF(code);
Py_XDECREF(varnames);
Expand Down
Loading