From e5822e7ecc3d95f506e749e6ef78aea0326fed0f Mon Sep 17 00:00:00 2001 From: An Long Date: Sun, 12 Jul 2026 21:54:28 +0900 Subject: [PATCH 1/5] Check PyLong_AsInt errors in legacy tracing --- Python/legacy_tracing.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Python/legacy_tracing.c b/Python/legacy_tracing.c index bf65a904de4d211..093a434bdb08281 100644 --- a/Python/legacy_tracing.c +++ b/Python/legacy_tracing.c @@ -353,6 +353,9 @@ sys_trace_line_func( } assert(PyVectorcall_NARGS(nargsf) == 2); int line = PyLong_AsInt(args[1]); + if (line == -1 && PyErr_Occurred()) { + return NULL; + } assert(line >= 0); PyFrameObject *frame = PyEval_GetFrame(); if (frame == NULL) { @@ -379,9 +382,17 @@ sys_trace_jump_func( Py_RETURN_NONE; } assert(PyVectorcall_NARGS(nargsf) == 3); - int from = PyLong_AsInt(args[1])/sizeof(_Py_CODEUNIT); + int from = PyLong_AsInt(args[1]); + if (from == -1 && PyErr_Occurred()) { + return NULL; + } + from /= sizeof(_Py_CODEUNIT); assert(from >= 0); - int to = PyLong_AsInt(args[2])/sizeof(_Py_CODEUNIT); + int to = PyLong_AsInt(args[2]); + if (to == -1 && PyErr_Occurred()) { + return NULL; + } + to /= sizeof(_Py_CODEUNIT); assert(to >= 0); if (to > from) { /* Forward jump */ From 32a3d98f2fbe970ac055282b6d303e05abd9cf90 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sun, 12 Jul 2026 13:56:37 +0000 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst new file mode 100644 index 000000000000000..748fdeaf763fb75 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst @@ -0,0 +1 @@ +Fix unchecked :c:func:PyLong_AsInt errors in the legacy tracing implementation. From 34272d09412c1c37d70ceb51171a98822e8a07df Mon Sep 17 00:00:00 2001 From: An Long Date: Sun, 12 Jul 2026 22:57:40 +0900 Subject: [PATCH 3/5] Update news entry --- .../2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst index 748fdeaf763fb75..f2d422c17700c37 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst @@ -1 +1 @@ -Fix unchecked :c:func:PyLong_AsInt errors in the legacy tracing implementation. +Fix unchecked :c:func:`PyLong_AsIn` errors in the legacy tracing implementation. From fcfb2f23bd462cda21ffdad7c35d46a117d25e5b Mon Sep 17 00:00:00 2001 From: An Long Date: Sun, 12 Jul 2026 23:15:29 +0900 Subject: [PATCH 4/5] Fix news entry --- .../2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst index f2d422c17700c37..3d8dc2ee37bc72e 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst @@ -1 +1 @@ -Fix unchecked :c:func:`PyLong_AsIn` errors in the legacy tracing implementation. +Fix unchecked :c:func:`PyLong_AsInt` errors in the legacy tracing implementation. From fb7acd217e688804789a8c47c1d2435180ab4c61 Mon Sep 17 00:00:00 2001 From: An Long Date: Mon, 13 Jul 2026 01:17:33 +0900 Subject: [PATCH 5/5] Remove the news entry file --- .../2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst deleted file mode 100644 index 3d8dc2ee37bc72e..000000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-07-12-13-56-25.gh-issue-153622.sVOw5K.rst +++ /dev/null @@ -1 +0,0 @@ -Fix unchecked :c:func:`PyLong_AsInt` errors in the legacy tracing implementation.