From 05773f94cd9ec95501fab8149ab8b892a57ff2e9 Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Sat, 2 Sep 2023 02:43:09 +0900 Subject: [PATCH] Add test --- Lib/test/test_monitoring.py | 9 ++++----- Python/instrumentation.c | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_monitoring.py b/Lib/test/test_monitoring.py index e69c9b2d9917df..7f1a63fe107178 100644 --- a/Lib/test/test_monitoring.py +++ b/Lib/test/test_monitoring.py @@ -1700,15 +1700,17 @@ def run(): sys.monitoring.set_events(TEST_TOOL, 0) -import _testinternalcapi class TestOptimizer(MonitoringTestBase, unittest.TestCase): def setUp(self): + import _testinternalcapi self.old_opt = _testinternalcapi.get_optimizer() opt = _testinternalcapi.get_counter_optimizer() + _testinternalcapi.set_optimizer(opt) super(TestOptimizer, self).setUp() def tearDown(self): + import _testinternalcapi super(TestOptimizer, self).tearDown() _testinternalcapi.set_optimizer(self.old_opt) @@ -1721,9 +1723,6 @@ def test_func(x): code = test_func.__code__ sys.monitoring.set_local_events(TEST_TOOL, code, E.PY_START) self.assertEqual(sys.monitoring.get_local_events(TEST_TOOL, code), E.PY_START) - sys.monitoring.set_local_events(TEST_TOOL2, code, E.PY_START) - self.assertEqual(sys.monitoring.get_local_events(TEST_TOOL2, code), E.PY_START) + test_func(1000) sys.monitoring.set_local_events(TEST_TOOL, code, 0) self.assertEqual(sys.monitoring.get_local_events(TEST_TOOL, code), 0) - sys.monitoring.set_local_events(TEST_TOOL2, code, 0) - self.assertEqual(sys.monitoring.get_local_events(TEST_TOOL2, code), 0) diff --git a/Python/instrumentation.c b/Python/instrumentation.c index 1ba7b832960e45..1ebab7be2577e0 100644 --- a/Python/instrumentation.c +++ b/Python/instrumentation.c @@ -1586,6 +1586,7 @@ _Py_Instrument(PyCodeObject *code, PyInterpreterState *interp) _Py_CODEUNIT *instr = &_PyCode_CODE(code)[i]; CHECK(instr->op.code != 0); int base_opcode = _Py_GetBaseOpcode(code, i); + assert(base_opcode != ENTER_EXECUTOR); if (opcode_has_event(base_opcode)) { int8_t event; if (base_opcode == RESUME) {