Skip to content

Commit f45c3cf

Browse files
committed
Fix stack_swap() return type
The 63-bit stack model was truncated to Kind (32-bit) on return; return int64_t and add a regression test.
1 parent 00ab207 commit f45c3cf

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎Lib/test/test_sys_settrace.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,6 +2113,16 @@ def test_jump_simple_backwards(output):
21132113
output.append(1)
21142114
output.append(2)
21152115

2116+
def test_backward_jump_deep_stack(self):
2117+
src = ["def f(output):"]
2118+
src += [" " * (i + 1) + f"for a{i} in [0]:" for i in range(6)]
2119+
src += [" " * 7 + "output.append(1)",
2120+
" " * 7 + "output[0], a5 = a5, output[0]",
2121+
" " * 7 + "output.append(2)"]
2122+
ns = {}
2123+
exec("\n".join(src), ns)
2124+
self.run_test(ns["f"], 9, 7, [1, 1, 2])
2125+
21162126
@jump_test(1, 4, [5], warning=(RuntimeWarning, unbound_locals))
21172127
def test_jump_is_none_forwards(output):
21182128
x = None

‎Objects/frameobject.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,7 @@ peek(int64_t stack, int n)
13131313
return (stack>>(BITS_PER_BLOCK*(n-1))) & MASK;
13141314
}
13151315

1316-
static Kind
1316+
static int64_t
13171317
stack_swap(int64_t stack, int n)
13181318
{
13191319
assert(n >= 1);

0 commit comments

Comments
 (0)