diff options
author | Mark Shannon <mark@hotpy.org> | 2024-08-01 09:27:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-01 09:27:26 +0100 |
commit | a9d56e38a08ec198a2289d8fff65444b39dd4a32 (patch) | |
tree | 86f180623f37e739812215964826fd48c7de873b /Python/executor_cases.c.h | |
parent | 46f5a4f9e1781ad8d60eb53bbaf6cd8534a286cd (diff) | |
download | cpython-a9d56e38a08ec198a2289d8fff65444b39dd4a32.tar.gz cpython-a9d56e38a08ec198a2289d8fff65444b39dd4a32.zip |
GH-122155: Track local variables between pops and pushes in cases generator (GH-122286)
Diffstat (limited to 'Python/executor_cases.c.h')
-rw-r--r-- | Python/executor_cases.c.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h index 62654035e80..f0acc3b6ea2 100644 --- a/Python/executor_cases.c.h +++ b/Python/executor_cases.c.h @@ -1440,9 +1440,11 @@ case _UNPACK_SEQUENCE: { _PyStackRef seq; + _PyStackRef *output; oparg = CURRENT_OPARG(); seq = stack_pointer[-1]; - _PyStackRef *top = stack_pointer + oparg - 1; + output = &stack_pointer[-1]; + _PyStackRef *top = output + oparg; int res = _PyEval_UnpackIterableStackRef(tstate, seq, oparg, -1, top); PyStackRef_CLOSE(seq); if (res == 0) JUMP_TO_ERROR(); @@ -1532,14 +1534,15 @@ case _UNPACK_EX: { _PyStackRef seq; + _PyStackRef *right; oparg = CURRENT_OPARG(); seq = stack_pointer[-1]; - int totalargs = 1 + (oparg & 0xFF) + (oparg >> 8); - _PyStackRef *top = stack_pointer + totalargs - 1; + right = &stack_pointer[(oparg & 0xFF)]; + _PyStackRef *top = right + (oparg >> 8); int res = _PyEval_UnpackIterableStackRef(tstate, seq, oparg & 0xFF, oparg >> 8, top); PyStackRef_CLOSE(seq); if (res == 0) JUMP_TO_ERROR(); - stack_pointer += (oparg >> 8) + (oparg & 0xFF); + stack_pointer += (oparg & 0xFF) + (oparg >> 8); assert(WITHIN_STACK_BOUNDS()); break; } @@ -3595,6 +3598,7 @@ args = &stack_pointer[-oparg]; self_or_null = stack_pointer[-1 - oparg]; callable = stack_pointer[-2 - oparg]; + args = &stack_pointer[-oparg]; if (PyStackRef_TYPE(callable) == &PyMethod_Type && PyStackRef_IsNull(self_or_null)) { PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable); PyObject *self = ((PyMethodObject *)callable_o)->im_self; |