From 04492cbc9aa45ac2c12d22083c406a0364c39f5b Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Thu, 22 Jun 2023 09:48:19 +0100 Subject: GH-91095: Specialize calls to normal Python classes. (GH-99331) --- Lib/test/test_sys_settrace.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'Lib/test/test_sys_settrace.py') diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py index 5603c3cdbf3..4462b5c712d 100644 --- a/Lib/test/test_sys_settrace.py +++ b/Lib/test/test_sys_settrace.py @@ -1614,8 +1614,30 @@ class TraceTestCase(unittest.TestCase): self.run_and_compare(func, EXPECTED_EVENTS) - def test_settrace_error(self): + def test_correct_tracing_quickened_call_class_init(self): + + class C: + def __init__(self): + self + + def func(): + C() + EXPECTED_EVENTS = [ + (0, 'call'), + (1, 'line'), + (-3, 'call'), + (-2, 'line'), + (-2, 'return'), + (1, 'return')] + + self.run_and_compare(func, EXPECTED_EVENTS) + # Quicken + for _ in range(100): + func() + self.run_and_compare(func, EXPECTED_EVENTS) + + def test_settrace_error(self): raised = False def error_once(frame, event, arg): nonlocal raised -- cgit v1.2.3