https://github.com/python/cpython/commit/688623d402097a2559fb135ce30384c884d9c78f
commit: 688623d402097a2559fb135ce30384c884d9c78f
branch: 3.12
author: Tian Gao <[email protected]>
committer: markshannon <[email protected]>
date: 2024-03-19T17:00:54Z
summary:
[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)
files:
A Misc/NEWS.d/next/Core and
Builtins/2024-03-13-16-55-25.gh-issue-116735.o3w6y8.rst
M Lib/test/test_monitoring.py
M Python/bytecodes.c
M Python/generated_cases.c.h
diff --git a/Lib/test/test_monitoring.py b/Lib/test/test_monitoring.py
index 383bb65a4cec08..d5d271fe548528 100644
--- a/Lib/test/test_monitoring.py
+++ b/Lib/test/test_monitoring.py
@@ -1745,9 +1745,10 @@ def test_gh108976(self):
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")
@@ -1756,5 +1757,7 @@ def f(a, b):
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))
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 00000000000000..ca15d484e345db
--- /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 ed8f671f63af1b..1c25486c3d4c5f 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -3209,7 +3209,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, next_instr-1, func, arg);
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index bb75e9a5ba7ba1..d5e3ce28ce264b 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -4435,7 +4435,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, next_instr-1, func, arg);
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]