FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GH-96636: Remove all uses of NOTRACE_DISPATCH by markshannon · Pull Request #96643 · python/cpython · GitHub

/ cpython Public
43 changes: 43 additions & 0 deletions Lib/test/test_dynamic.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,48 @@ def __missing__(self, key):
for _ in range(30):
self.assertEqual(sum_func(), expected)


class TestTracing(unittest.TestCase):

def setUp(self):
self.addCleanup(sys.settrace, sys.gettrace())
sys.settrace(None)

def test_after_specialization(self):

def trace(frame, event, arg):
return trace

turn_on_trace = False

class C:
def __init__(self, x):
self.x = x
def __del__(self):
if turn_on_trace:
sys.settrace(trace)

def f():
# LOAD_GLOBAL[_BUILTIN] immediately follows the call to C.__del__
C(0).x, len

def g():
# BINARY_SUSCR[_LIST_INT] immediately follows the call to C.__del__
[0][C(0).x]

def h():
# BINARY_OP[_ADD_INT] immediately follows the call to C.__del__
0 + C(0).x

for func in (f, g, h):
with self.subTest(func.__name__):
for _ in range(58):
Comment thread
markshannon marked this conversation as resolved.
Comment thread
markshannon marked this conversation as resolved.
func()
turn_on_trace = True
func()
Comment thread
markshannon marked this conversation as resolved.
sys.settrace(None)
turn_on_trace = False


if __name__ == "__main__":
unittest.main()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Ensure that tracing, ``sys.setrace()``, is turned on immediately. In
pre-release versions of 3.11, some tracing events might have been lost when
turning on tracing in a ``__del__`` method or interrupt.
Loading

Back | FazBrowse Home | New Git URL