Skip to content

Commit 2814c23

Browse files
committed
Fix reference counting in _PyMonitoring_RegisterCallback
1 parent c5a4b17 commit 2814c23

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Python/instrumentation.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2932,11 +2932,11 @@ static PyObject *make_branch_handler(int tool_id, PyObject *handler, bool right)
29322932
return (PyObject *)callback;
29332933
}
29342934

2935+
/* Consumes a reference to obj */
29352936
static PyObject *exchange_callables(int tool_id, int event_id, PyObject *obj)
29362937
{
29372938
PyInterpreterState *is = _PyInterpreterState_GET();
2938-
return _Py_atomic_exchange_ptr(&is->monitoring_callables[tool_id][event_id],
2939-
Py_XNewRef(obj));
2939+
return _Py_atomic_exchange_ptr(&is->monitoring_callables[tool_id][event_id], obj);
29402940
}
29412941

29422942
PyObject *

0 commit comments

Comments
 (0)