From ad5d5c23baed1bb69c4885c021398c4c791953a1 Mon Sep 17 00:00:00 2001 From: lipengyu Date: Mon, 25 May 2026 17:29:32 +0800 Subject: [PATCH 1/3] Fix PyLong ref leak in C API monitoring events --- Python/instrumentation.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Python/instrumentation.c b/Python/instrumentation.c index 51bcbfdb3b6c55..0af2070b5cd983 100644 --- a/Python/instrumentation.c +++ b/Python/instrumentation.c @@ -2630,8 +2630,9 @@ capi_call_instrumentation(PyMonitoringState *state, PyObject *codelike, int32_t PyErr_SetString(PyExc_ValueError, "offset must be non-negative"); return -1; } + PyObject *offset_obj = NULL; if (event != PY_MONITORING_EVENT_LINE) { - PyObject *offset_obj = PyLong_FromLong(offset); + offset_obj = PyLong_FromLong(offset); if (offset_obj == NULL) { return -1; } @@ -2672,6 +2673,7 @@ capi_call_instrumentation(PyMonitoringState *state, PyObject *codelike, int32_t } } } + Py_XDECREF(offset_obj); return err; } From 81b579c4b548c7273fb79ec407b78ffb7440491a Mon Sep 17 00:00:00 2001 From: lipengyu Date: Mon, 25 May 2026 17:54:08 +0800 Subject: [PATCH 2/3] add NEWS entry --- .../next/C_API/2026-05-25-17-53-16.gh-issue-150379.1y54ks.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/C_API/2026-05-25-17-53-16.gh-issue-150379.1y54ks.rst diff --git a/Misc/NEWS.d/next/C_API/2026-05-25-17-53-16.gh-issue-150379.1y54ks.rst b/Misc/NEWS.d/next/C_API/2026-05-25-17-53-16.gh-issue-150379.1y54ks.rst new file mode 100644 index 00000000000000..49d9dc50520fa9 --- /dev/null +++ b/Misc/NEWS.d/next/C_API/2026-05-25-17-53-16.gh-issue-150379.1y54ks.rst @@ -0,0 +1 @@ +Fix a reference leak of the offset argument in C API monitoring event calls. From a52ca4d46be6d5456552d54726ace79987511cda Mon Sep 17 00:00:00 2001 From: lipengyu Date: Mon, 25 May 2026 18:02:48 +0800 Subject: [PATCH 3/3] delete NEWS entry --- .../next/C_API/2026-05-25-17-53-16.gh-issue-150379.1y54ks.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/C_API/2026-05-25-17-53-16.gh-issue-150379.1y54ks.rst diff --git a/Misc/NEWS.d/next/C_API/2026-05-25-17-53-16.gh-issue-150379.1y54ks.rst b/Misc/NEWS.d/next/C_API/2026-05-25-17-53-16.gh-issue-150379.1y54ks.rst deleted file mode 100644 index 49d9dc50520fa9..00000000000000 --- a/Misc/NEWS.d/next/C_API/2026-05-25-17-53-16.gh-issue-150379.1y54ks.rst +++ /dev/null @@ -1 +0,0 @@ -Fix a reference leak of the offset argument in C API monitoring event calls.