mirror of https://github.com/python/cpython
gh-116735: Use `MISSING` for `CALL` event if argument is absent (GH-116737)
This commit is contained in:
parent
d180b507c4
commit
59e30f41ed
|
@ -1808,9 +1808,10 @@ class TestRegressions(MonitoringTestBase, unittest.TestCase):
|
||||||
sys.monitoring.set_events(0, 0)
|
sys.monitoring.set_events(0, 0)
|
||||||
|
|
||||||
def test_call_function_ex(self):
|
def test_call_function_ex(self):
|
||||||
def f(a, b):
|
def f(a=1, b=2):
|
||||||
return a + b
|
return a + b
|
||||||
args = (1, 2)
|
args = (1, 2)
|
||||||
|
empty_args = []
|
||||||
|
|
||||||
call_data = []
|
call_data = []
|
||||||
sys.monitoring.use_tool_id(0, "test")
|
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.register_callback(0, E.CALL, lambda code, offset, callable, arg0: call_data.append((callable, arg0)))
|
||||||
sys.monitoring.set_events(0, E.CALL)
|
sys.monitoring.set_events(0, E.CALL)
|
||||||
f(*args)
|
f(*args)
|
||||||
|
f(*empty_args)
|
||||||
sys.monitoring.set_events(0, 0)
|
sys.monitoring.set_events(0, 0)
|
||||||
self.assertEqual(call_data[0], (f, 1))
|
self.assertEqual(call_data[0], (f, 1))
|
||||||
|
self.assertEqual(call_data[1], (f, sys.monitoring.MISSING))
|
||||||
|
|
||||||
|
|
||||||
class TestOptimizer(MonitoringTestBase, unittest.TestCase):
|
class TestOptimizer(MonitoringTestBase, unittest.TestCase):
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
For ``INSTRUMENTED_CALL_FUNCTION_EX``, set ``arg0`` to ``sys.monitoring.MISSING`` instead of ``None`` for :monitoring-event:`CALL` event.
|
|
@ -3774,7 +3774,7 @@ dummy_func(
|
||||||
EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_FUNCTION_EX, func);
|
EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_FUNCTION_EX, func);
|
||||||
if (opcode == INSTRUMENTED_CALL_FUNCTION_EX) {
|
if (opcode == INSTRUMENTED_CALL_FUNCTION_EX) {
|
||||||
PyObject *arg = PyTuple_GET_SIZE(callargs) > 0 ?
|
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(
|
int err = _Py_call_instrumentation_2args(
|
||||||
tstate, PY_MONITORING_EVENT_CALL,
|
tstate, PY_MONITORING_EVENT_CALL,
|
||||||
frame, this_instr, func, arg);
|
frame, this_instr, func, arg);
|
||||||
|
|
|
@ -1227,7 +1227,7 @@
|
||||||
EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_FUNCTION_EX, func);
|
EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_FUNCTION_EX, func);
|
||||||
if (opcode == INSTRUMENTED_CALL_FUNCTION_EX) {
|
if (opcode == INSTRUMENTED_CALL_FUNCTION_EX) {
|
||||||
PyObject *arg = PyTuple_GET_SIZE(callargs) > 0 ?
|
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(
|
int err = _Py_call_instrumentation_2args(
|
||||||
tstate, PY_MONITORING_EVENT_CALL,
|
tstate, PY_MONITORING_EVENT_CALL,
|
||||||
frame, this_instr, func, arg);
|
frame, this_instr, func, arg);
|
||||||
|
|
Loading…
Reference in New Issue