Skip to content

Commit 688623d

Browse files
[3.12] gh-116735: Use MISSING for CALL event if argument is absen… (#116873)
[3.12] gh-116735: Use `MISSING` for `CALL` event if argument is absent (GH-116737)
1 parent 5da6e30 commit 688623d

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

Lib/test/test_monitoring.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1745,9 +1745,10 @@ def test_gh108976(self):
17451745
sys.monitoring.set_events(0, 0)
17461746

17471747
def test_call_function_ex(self):
1748-
def f(a, b):
1748+
def f(a=1, b=2):
17491749
return a + b
17501750
args = (1, 2)
1751+
empty_args = []
17511752

17521753
call_data = []
17531754
sys.monitoring.use_tool_id(0, "test")
@@ -1756,5 +1757,7 @@ def f(a, b):
17561757
sys.monitoring.register_callback(0, E.CALL, lambda code, offset, callable, arg0: call_data.append((callable, arg0)))
17571758
sys.monitoring.set_events(0, E.CALL)
17581759
f(*args)
1760+
f(*empty_args)
17591761
sys.monitoring.set_events(0, 0)
17601762
self.assertEqual(call_data[0], (f, 1))
1763+
self.assertEqual(call_data[1], (f, sys.monitoring.MISSING))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
For ``INSTRUMENTED_CALL_FUNCTION_EX``, set ``arg0`` to ``sys.monitoring.MISSING`` instead of ``None`` for :monitoring-event:`CALL` event.

Python/bytecodes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3209,7 +3209,7 @@ dummy_func(
32093209
EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_FUNCTION_EX, func);
32103210
if (opcode == INSTRUMENTED_CALL_FUNCTION_EX) {
32113211
PyObject *arg = PyTuple_GET_SIZE(callargs) > 0 ?
3212-
PyTuple_GET_ITEM(callargs, 0) : Py_None;
3212+
PyTuple_GET_ITEM(callargs, 0) : &_PyInstrumentation_MISSING;
32133213
int err = _Py_call_instrumentation_2args(
32143214
tstate, PY_MONITORING_EVENT_CALL,
32153215
frame, next_instr-1, func, arg);

Python/generated_cases.c.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)