[3.12] gh-109371: Fix monitoring with instruction events set (gh-109385) (#109542)

gh-109371: Fix monitoring with instruction events set (gh-109385)
(cherry picked from commit 412f5e85d6)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
This commit is contained in:
Miss Islington (bot) 2023-09-18 08:40:51 -07:00 committed by GitHub
parent 2401b980da
commit 9412a874a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 2 deletions

View file

@ -501,6 +501,22 @@ class MultipleMonitorsTest(MonitoringTestBase, unittest.TestCase):
self.assertEqual(sys.monitoring._all_events(), {})
sys.monitoring.restart_events()
def test_with_instruction_event(self):
"""Test that the second tool can set events with instruction events set by the first tool."""
def f():
pass
code = f.__code__
try:
self.assertEqual(sys.monitoring._all_events(), {})
sys.monitoring.set_local_events(TEST_TOOL, code, E.INSTRUCTION | E.LINE)
sys.monitoring.set_local_events(TEST_TOOL2, code, E.LINE)
finally:
sys.monitoring.set_events(TEST_TOOL, 0)
sys.monitoring.set_events(TEST_TOOL2, 0)
self.assertEqual(sys.monitoring._all_events(), {})
class LineMonitoringTest(MonitoringTestBase, unittest.TestCase):
def test_lines_single(self):