summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorTian Gao <gaogaotiantian@hotmail.com>2024-08-08 04:30:14 (GMT)
committerGitHub <noreply@github.com>2024-08-08 04:30:14 (GMT)
commit57d7c3e78fb635a0c6ccce38ec3e2f4284d5fac7 (patch)
tree03f9f2f24adb6313838a586240dee6374a9dd4d2 /Lib/test
parente006c7371d8e57db26254792c67292956e88d81d (diff)
downloadcpython-57d7c3e78fb635a0c6ccce38ec3e2f4284d5fac7.zip
cpython-57d7c3e78fb635a0c6ccce38ec3e2f4284d5fac7.tar.gz
cpython-57d7c3e78fb635a0c6ccce38ec3e2f4284d5fac7.tar.bz2
gh-122247: Move instruction instrumentation sanity check after tracing check (#122251)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_monitoring.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_monitoring.py b/Lib/test/test_monitoring.py
index d7043cd..8ef8c37 100644
--- a/Lib/test/test_monitoring.py
+++ b/Lib/test/test_monitoring.py
@@ -1863,6 +1863,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):