Repository navigation
Closed
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixestestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Running any of TraceOpcodesTestCase tests from test_sys_settrace always fails. For example:
$ ./python -m test -v test_sys_settrace -m test.test_sys_settrace.TraceOpcodesTestCase.test_01_basic
...
test_01_basic (test.test_sys_settrace.TraceOpcodesTestCase.test_01_basic) ... FAIL
======================================================================
FAIL: test_01_basic (test.test_sys_settrace.TraceOpcodesTestCase.test_01_basic)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/serhiy/py/cpython/Lib/test/test_sys_settrace.py", line 388, in test_01_basic
self.run_test(basic)
File "/home/serhiy/py/cpython/Lib/test/test_sys_settrace.py", line 364, in run_test
self.run_and_compare(func, func.events)
File "/home/serhiy/py/cpython/Lib/test/test_sys_settrace.py", line 360, in run_and_compare
self.compare_events(func.__code__.co_firstlineno,
File "/home/serhiy/py/cpython/Lib/test/test_sys_settrace.py", line 1745, in compare_events
self.assertLess(len(skip_opcode_events), len(events),
AssertionError: 3 not less than 3 : No 'opcode' events received by the tracer
...
Running several of TraceOpcodesTestCase tests only fails the first of them.
Running also RaisingTraceFuncTestCase.test_line_event_raises_before_opcode_event makes the tests passing successfully.
$ ./python -m test -v test_sys_settrace -m test.test_sys_settrace.TraceOpcodesTestCase.test_01_basic -m test_line_event_raises_before_opcode_event
...
test_line_event_raises_before_opcode_event (test.test_sys_settrace.RaisingTraceFuncTestCase.test_line_event_raises_before_opcode_event) ... ok
test_01_basic (test.test_sys_settrace.TraceOpcodesTestCase.test_01_basic) ... ok
...
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixestestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
serhiy-storchaka commentedon Sep 6, 2023
It is only reproduced in 3.12+.
gaogaotiantian commentedon Sep 6, 2023
This is a known issue #103615. I have not had the chance to fix it. The issue is that you can't start the trace before you set
trace_opcode = True. It's an underlying tracing mechanism problem that requires some architecture change.serhiy-storchaka commentedon Sep 6, 2023
Is there a workaround for tests which does not invalidate the purposes of tests?
#103615 did not mention test_sys_settrace. Should we close this issue or keep it until #103615 be solved to ensure that this issue also is fixed?
gaogaotiantian commentedon Sep 6, 2023
I can do a hacky workaround if that's what needed for now - basically we just need to ensure
f_trace_opcodesis set toTrueat least once on ANY frame before we start tracing. It that helps the validation, I can do the PR - it's pretty trivial. We should, however, remove it when it's not needed.#108976 is not fixed after the workaround though. It has a deeper issue.