From: Ken Jin Date: Sat, 1 Nov 2025 18:41:01 +0000 (+0800) Subject: [3.14] gh-140104: Revert "Set next_instr properly in the JIT during exceptions (GH... X-Git-Tag: v3.14.1~257 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d68b758fa0a18c949d7d2f22dde091c8d7a3ba7;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-140104: Revert "Set next_instr properly in the JIT during exceptions (GH-140233) (GH-140687)" (#140890) Revert "[3.14] gh-140104: Set next_instr properly in the JIT during exceptions (GH-140233) (GH-140687)" This reverts commit 2e216728038a03d387231f39ded091ec318ba61b. --- diff --git a/Lib/test/test_capi/test_opt.py b/Lib/test/test_capi/test_opt.py index bdcda12c76e1..c74c8ee0eef8 100644 --- a/Lib/test/test_capi/test_opt.py +++ b/Lib/test/test_capi/test_opt.py @@ -1972,27 +1972,6 @@ class TestUopsOptimization(unittest.TestCase): assert ex is not None """)) - def test_next_instr_for_exception_handler_set(self): - # gh-140104: We just want the exception to be caught properly. - def f(): - for i in range(TIER2_THRESHOLD + 3): - try: - undefined_variable(i) - except Exception: - pass - - f() - - def test_next_instr_for_exception_handler_set_lasts_instr(self): - # gh-140104: We just want the exception to be caught properly. - def f(): - a_list = [] - for _ in range(TIER2_THRESHOLD + 3): - try: - a_list[""] = 0 - except Exception: - pass - def global_identity(x): return x diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-10-16-21-47-00.gh-issue-140104.A8SQIm.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-10-16-21-47-00.gh-issue-140104.A8SQIm.rst deleted file mode 100644 index 1c18cbc9ad05..000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2025-10-16-21-47-00.gh-issue-140104.A8SQIm.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a bug with exception handling in the JIT. Patch by Ken Jin. Bug reported -by Daniel Diniz. diff --git a/Python/ceval_macros.h b/Python/ceval_macros.h index df1950416c2d..187ec8fdd265 100644 --- a/Python/ceval_macros.h +++ b/Python/ceval_macros.h @@ -368,9 +368,7 @@ do { \ frame = tstate->current_frame; \ stack_pointer = _PyFrame_GetStackPointer(frame); \ if (next_instr == NULL) { \ - /* gh-140104: The exception handler expects frame->instr_ptr - to after this_instr, not this_instr! */ \ - next_instr = frame->instr_ptr + 1; \ + next_instr = frame->instr_ptr; \ JUMP_TO_LABEL(error); \ } \ DISPATCH(); \