From 394f2e0e7a2b693b247481010f786d6bf2847035 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Sat, 4 Mar 2023 10:29:24 -0800 Subject: [PATCH] Whoops, cannot use DECREF_INPUTS() in some cases --- Python/bytecodes.c | 10 +++++----- Python/generated_cases.c.h | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Python/bytecodes.c b/Python/bytecodes.c index df03f857a55043..f465ad57503519 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -1949,7 +1949,7 @@ dummy_func( else { err = PyObject_IsTrue(cond); if (err > 0) { - DECREF_INPUTS(); + Py_DECREF(cond); } else if (err == 0) { JUMPBY(oparg); @@ -1978,7 +1978,7 @@ dummy_func( jump = true; } else if (err == 0) { - DECREF_INPUTS(); + Py_DECREF(cond); } else { goto error; @@ -2111,7 +2111,7 @@ dummy_func( } /* iterator ended normally */ assert(next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == END_FOR); - DECREF_INPUTS(); + Py_DECREF(iter); STACK_SHRINK(1); /* Jump forward oparg, then skip following END_FOR instruction */ JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1); @@ -2134,7 +2134,7 @@ dummy_func( it->it_seq = NULL; Py_DECREF(seq); } - DECREF_INPUTS(); + Py_DECREF(iter); STACK_SHRINK(1); /* Jump forward oparg, then skip following END_FOR instruction */ JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1); @@ -2157,7 +2157,7 @@ dummy_func( it->it_seq = NULL; Py_DECREF(seq); } - DECREF_INPUTS(); + Py_DECREF(iter); STACK_SHRINK(1); /* Jump forward oparg, then skip following END_FOR instruction */ JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1); diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index d7320f755199a0..93909165862111 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -2471,6 +2471,7 @@ else { err = PyObject_IsTrue(cond); if (err > 0) { + Py_DECREF(cond); } else if (err == 0) { JUMPBY(oparg); @@ -2503,6 +2504,7 @@ jump = true; } else if (err == 0) { + Py_DECREF(cond); } else { goto error; @@ -2667,6 +2669,7 @@ } /* iterator ended normally */ assert(next_instr[INLINE_CACHE_ENTRIES_FOR_ITER + oparg].op.code == END_FOR); + Py_DECREF(iter); STACK_SHRINK(1); /* Jump forward oparg, then skip following END_FOR instruction */ JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1); @@ -2695,6 +2698,7 @@ it->it_seq = NULL; Py_DECREF(seq); } + Py_DECREF(iter); STACK_SHRINK(1); /* Jump forward oparg, then skip following END_FOR instruction */ JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1); @@ -2723,6 +2727,7 @@ it->it_seq = NULL; Py_DECREF(seq); } + Py_DECREF(iter); STACK_SHRINK(1); /* Jump forward oparg, then skip following END_FOR instruction */ JUMPBY(INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1);