mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
[3.13] gh-122247: Move instruction instrumentation sanity check after tracing check (GH-122251) (GH-122812)
(cherry picked from commit 57d7c3e78f
)
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
This commit is contained in:
parent
7ee7558833
commit
1f7071572e
2 changed files with 16 additions and 1 deletions
|
@ -1841,6 +1841,21 @@ class TestRegressions(MonitoringTestBase, unittest.TestCase):
|
|||
self.assertEqual(call_data[0], (f, 1))
|
||||
self.assertEqual(call_data[1], (f, sys.monitoring.MISSING))
|
||||
|
||||
def test_instruction_explicit_callback(self):
|
||||
# gh-122247
|
||||
# Calling the instruction event callback explicitly should not
|
||||
# crash CPython
|
||||
def callback(code, instruction_offset):
|
||||
pass
|
||||
|
||||
sys.monitoring.use_tool_id(0, "test")
|
||||
self.addCleanup(sys.monitoring.free_tool_id, 0)
|
||||
sys.monitoring.register_callback(0, sys.monitoring.events.INSTRUCTION, callback)
|
||||
sys.monitoring.set_events(0, sys.monitoring.events.INSTRUCTION)
|
||||
callback(None, 0) # call the *same* handler while it is registered
|
||||
sys.monitoring.restart_events()
|
||||
sys.monitoring.set_events(0, 0)
|
||||
|
||||
|
||||
class TestOptimizer(MonitoringTestBase, unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue