Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Lib/test/test_frame.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import copy

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / WASI / build and test

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / Lazy imports enabled / Run Tests with lazy_imports=all

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04-arm)

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / macOS / build and test (macos-26)

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / Hypothesis tests on Ubuntu

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-26.04)

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-26.04-arm)

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / Windows / Build and test (x64, switch-case)

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / Ubuntu (bolt) / build and test (ubuntu-26.04)

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-26.04)

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / macOS (free-threading) / build and test (macos-26)

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / macOS / build and test (macos-26-intel)

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / Windows / Build and test (arm64, switch-case)

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / Sanitizers / ASan

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / Sanitizers / UBSan

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / Windows / Build and test (Win32, switch-case)

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (x64, switch-case)

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / Sanitizers / MSan

test_frame

test_frame worker non-zero exit code

Check failure on line 1 in Lib/test/test_frame.py

View workflow job for this annotation

GitHub Actions / Windows (free-threading) / Build and test (arm64, switch-case)

test_frame

test_frame worker non-zero exit code
import operator
import re
import sys
import textwrap
import threading
import unittest
import warnings
import weakref
try:
import _testcapi
Expand Down Expand Up @@ -222,6 +223,30 @@
with self.assertRaises(AttributeError):
del f.f_lineno

def test_f_lineno_deep_stack_swap(self):
fors = " ".join(f"for v{i} in range(1)" for i in range(11))
params = ", ".join(f"v{i}=None" for i in range(11))
ns = {}
exec(f"def f({params}):\n return [0 {fors}]\n", ns)
f = ns["f"]

jumped = []

def tracer(frame, event, arg):
if (event == 'line' and frame.f_code is f.__code__
and not jumped):
jumped.append(None)
frame.f_lineno = frame.f_lineno
return tracer

with warnings.catch_warnings():
warnings.simplefilter('ignore', RuntimeWarning)
sys.settrace(tracer)
try:
self.assertEqual(f(), [0])
finally:
sys.settrace(None)

def test_f_trace(self):
f, _, _ = self.make_frames()
def tracer(*args):
Expand Down
3 changes: 2 additions & 1 deletion Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,8 @@ stack_swap(int64_t stack, int n)
Kind to_swap = peek(stack, n);
Kind top = top_of_stack(stack);
int shift = BITS_PER_BLOCK*(n-1);
int64_t replaced_low = (stack & ~(MASK << shift)) | (top << shift);
int64_t replaced_low = (stack & ~((int64_t)MASK << shift))
| ((int64_t)top << shift);
int64_t replaced_top = (replaced_low & ~MASK) | to_swap;
return replaced_top;
}
Expand Down
Loading