summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_monitoring.py5
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2024-03-13-16-55-25.gh-issue-116735.o3w6y8.rst1
-rw-r--r--Python/bytecodes.c2
-rw-r--r--Python/generated_cases.c.h2
4 files changed, 7 insertions, 3 deletions
diff --git a/Lib/test/test_monitoring.py b/Lib/test/test_monitoring.py
index 11fb2d8..58441ef 100644
--- a/Lib/test/test_monitoring.py
+++ b/Lib/test/test_monitoring.py
@@ -1808,9 +1808,10 @@ class TestRegressions(MonitoringTestBase, unittest.TestCase):
sys.monitoring.set_events(0, 0)
def test_call_function_ex(self):
- def f(a, b):
+ def f(a=1, b=2):
return a + b
args = (1, 2)
+ empty_args = []
call_data = []
sys.monitoring.use_tool_id(0, "test")
@@ -1819,8 +1820,10 @@ class TestRegressions(MonitoringTestBase, unittest.TestCase):
sys.monitoring.register_callback(0, E.CALL, lambda code, offset, callable, arg0: call_data.append((callable, arg0)))
sys.monitoring.set_events(0, E.CALL)
f(*args)
+ f(*empty_args)
sys.monitoring.set_events(0, 0)
self.assertEqual(call_data[0], (f, 1))
+ self.assertEqual(call_data[1], (f, sys.monitoring.MISSING))
class TestOptimizer(MonitoringTestBase, unittest.TestCase):
diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-03-13-16-55-25.gh-issue-116735.o3w6y8.rst b/Misc/NEWS.d/next/Core and Builtins/2024-03-13-16-55-25.gh-issue-116735.o3w6y8.rst
new file mode 100644
index 0000000..ca15d48
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2024-03-13-16-55-25.gh-issue-116735.o3w6y8.rst
@@ -0,0 +1 @@
+For ``INSTRUMENTED_CALL_FUNCTION_EX``, set ``arg0`` to ``sys.monitoring.MISSING`` instead of ``None`` for :monitoring-event:`CALL` event.
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index bf7782a..fb66ae5 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -3774,7 +3774,7 @@ dummy_func(
EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_FUNCTION_EX, func);
if (opcode == INSTRUMENTED_CALL_FUNCTION_EX) {
PyObject *arg = PyTuple_GET_SIZE(callargs) > 0 ?
- PyTuple_GET_ITEM(callargs, 0) : Py_None;
+ PyTuple_GET_ITEM(callargs, 0) : &_PyInstrumentation_MISSING;
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_CALL,
frame, this_instr, func, arg);
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index 2fbd9ed..82d7b76 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -1227,7 +1227,7 @@
EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_FUNCTION_EX, func);
if (opcode == INSTRUMENTED_CALL_FUNCTION_EX) {
PyObject *arg = PyTuple_GET_SIZE(callargs) > 0 ?
- PyTuple_GET_ITEM(callargs, 0) : Py_None;
+ PyTuple_GET_ITEM(callargs, 0) : &_PyInstrumentation_MISSING;
int err = _Py_call_instrumentation_2args(
tstate, PY_MONITORING_EVENT_CALL,
frame, this_instr, func, arg);