From f3fab465c5dccf6e262391a287820ebf7230edc0 Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Sat, 30 Mar 2024 11:58:37 -0700 Subject: [PATCH 1/2] Remove some unnecessary code in instrumentation code --- Python/instrumentation.c | 2 +- Python/sysmodule.c | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Python/instrumentation.c b/Python/instrumentation.c index 018cd662b1561a..dfcaf6d97e46ce 100644 --- a/Python/instrumentation.c +++ b/Python/instrumentation.c @@ -1197,7 +1197,7 @@ _Py_call_instrumentation_line(PyThreadState *tstate, _PyInterpreterFrame* frame, /* Special case sys.settrace to avoid boxing the line number, * only to immediately unbox it. */ if (tools & (1 << PY_MONITORING_SYS_TRACE_ID)) { - if (tstate->c_tracefunc != NULL && line >= 0) { + if (tstate->c_tracefunc != NULL) { PyFrameObject *frame_obj = _PyFrame_GetFrameObject(frame); if (frame_obj == NULL) { return -1; diff --git a/Python/sysmodule.c b/Python/sysmodule.c index cd193c1581c679..704413a00c7db2 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1079,9 +1079,6 @@ trace_trampoline(PyObject *self, PyFrameObject *frame, if (result != Py_None) { Py_XSETREF(frame->f_trace, result); } - else { - Py_DECREF(result); - } return 0; } From 8d5db73ceefa4040b11c2d04884c55c044227979 Mon Sep 17 00:00:00 2001 From: Tian Gao Date: Mon, 1 Apr 2024 21:38:48 -0700 Subject: [PATCH 2/2] Revert removing Py_DECREF for None --- Python/sysmodule.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 704413a00c7db2..cd193c1581c679 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1079,6 +1079,9 @@ trace_trampoline(PyObject *self, PyFrameObject *frame, if (result != Py_None) { Py_XSETREF(frame->f_trace, result); } + else { + Py_DECREF(result); + } return 0; }