summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-05-26 12:59:29 (GMT)
committerGitHub <noreply@github.com>2024-05-26 12:59:29 (GMT)
commit825a5ae5d89547e2ec74ba7e665592eabe56c435 (patch)
treec17f345a8378123a376d5e0341a237aa88b74dff /Python
parent3f0198d927398ca843097bc2b03aa616a7d35c6e (diff)
downloadcpython-825a5ae5d89547e2ec74ba7e665592eabe56c435.zip
cpython-825a5ae5d89547e2ec74ba7e665592eabe56c435.tar.gz
cpython-825a5ae5d89547e2ec74ba7e665592eabe56c435.tar.bz2
[3.13] gh-111997: Fix argument count for LINE event and clarify type of argument counts. (GH-119179) (GH-119575)
gh-111997: Fix argument count for LINE event and clarify type of argument counts. (GH-119179) (cherry picked from commit 70b07aa4153c1a914a3d69307d5b258cf7ed16ab) Co-authored-by: scoder <stefan_ml@behnel.de>
Diffstat (limited to 'Python')
-rw-r--r--Python/instrumentation.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/Python/instrumentation.c b/Python/instrumentation.c
index 9095fb9..a5211ee 100644
--- a/Python/instrumentation.c
+++ b/Python/instrumentation.c
@@ -893,7 +893,7 @@ remove_per_instruction_tools(PyCodeObject * code, int offset, int tools)
static int
call_one_instrument(
PyInterpreterState *interp, PyThreadState *tstate, PyObject **args,
- Py_ssize_t nargsf, int8_t tool, int event)
+ size_t nargsf, int8_t tool, int event)
{
assert(0 <= tool && tool < 8);
assert(tstate->tracing == 0);
@@ -1084,7 +1084,7 @@ call_instrumentation_vector(
args[2] = offset_obj;
PyInterpreterState *interp = tstate->interp;
uint8_t tools = get_tools_for_instruction(code, interp, offset, event);
- Py_ssize_t nargsf = nargs | PY_VECTORCALL_ARGUMENTS_OFFSET;
+ size_t nargsf = (size_t) nargs | PY_VECTORCALL_ARGUMENTS_OFFSET;
PyObject **callargs = &args[1];
int err = 0;
while (tools) {
@@ -2439,13 +2439,15 @@ capi_call_instrumentation(PyMonitoringState *state, PyObject *codelike, int32_t
PyErr_SetString(PyExc_ValueError, "offset must be non-negative");
return -1;
}
- PyObject *offset_obj = PyLong_FromLong(offset);
- if (offset_obj == NULL) {
- return -1;
+ if (event != PY_MONITORING_EVENT_LINE) {
+ PyObject *offset_obj = PyLong_FromLong(offset);
+ if (offset_obj == NULL) {
+ return -1;
+ }
+ assert(args[2] == NULL);
+ args[2] = offset_obj;
}
- assert(args[2] == NULL);
- args[2] = offset_obj;
- Py_ssize_t nargsf = nargs | PY_VECTORCALL_ARGUMENTS_OFFSET;
+ size_t nargsf = (size_t) nargs | PY_VECTORCALL_ARGUMENTS_OFFSET;
PyObject **callargs = &args[1];
int err = 0;
@@ -2565,8 +2567,8 @@ _PyMonitoring_FireLineEvent(PyMonitoringState *state, PyObject *codelike, int32_
if (lno == NULL) {
return -1;
}
- PyObject *args[4] = { NULL, NULL, NULL, lno };
- int res= capi_call_instrumentation(state, codelike, offset, args, 3,
+ PyObject *args[3] = { NULL, NULL, lno };
+ int res= capi_call_instrumentation(state, codelike, offset, args, 2,
PY_MONITORING_EVENT_LINE);
Py_DECREF(lno);
return res;