Skip to content

Commit aa3b4cf

Browse files
GH-96636: Remove all uses of NOTRACE_DISPATCH (GH-96643)
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
1 parent b9634ac commit aa3b4cf

File tree

3 files changed

+105
-62
lines changed

3 files changed

+105
-62
lines changed

Lib/test/test_dynamic.py

+43
Original file line numberDiff line numberDiff line change
@@ -149,5 +149,48 @@ def __missing__(self, key):
149149
for _ in range(30):
150150
self.assertEqual(sum_func(), expected)
151151

152+
153+
class TestTracing(unittest.TestCase):
154+
155+
def setUp(self):
156+
self.addCleanup(sys.settrace, sys.gettrace())
157+
sys.settrace(None)
158+
159+
def test_after_specialization(self):
160+
161+
def trace(frame, event, arg):
162+
return trace
163+
164+
turn_on_trace = False
165+
166+
class C:
167+
def __init__(self, x):
168+
self.x = x
169+
def __del__(self):
170+
if turn_on_trace:
171+
sys.settrace(trace)
172+
173+
def f():
174+
# LOAD_GLOBAL[_BUILTIN] immediately follows the call to C.__del__
175+
C(0).x, len
176+
177+
def g():
178+
# BINARY_SUSCR[_LIST_INT] immediately follows the call to C.__del__
179+
[0][C(0).x]
180+
181+
def h():
182+
# BINARY_OP[_ADD_INT] immediately follows the call to C.__del__
183+
0 + C(0).x
184+
185+
for func in (f, g, h):
186+
with self.subTest(func.__name__):
187+
for _ in range(58):
188+
func()
189+
turn_on_trace = True
190+
func()
191+
sys.settrace(None)
192+
turn_on_trace = False
193+
194+
152195
if __name__ == "__main__":
153196
unittest.main()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Ensure that tracing, ``sys.setrace()``, is turned on immediately. In
2+
pre-release versions of 3.11, some tracing events might have been lost when
3+
turning on tracing in a ``__del__`` method or interrupt.

0 commit comments

Comments
 (0)