Skip to content

Commit 0a54bd6

Browse files
authored
gh-111178: Fix function signatures in legacy_tracing.c (#131464)
1 parent 6935d96 commit 0a54bd6

File tree

1 file changed

+38
-27
lines changed

1 file changed

+38
-27
lines changed

Python/legacy_tracing.c

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,10 @@ call_trace_func(_PyLegacyEventHandler *self, PyObject *arg)
183183

184184
static PyObject *
185185
sys_trace_exception_func(
186-
_PyLegacyEventHandler *self, PyObject *const *args,
186+
PyObject *callable, PyObject *const *args,
187187
size_t nargsf, PyObject *kwnames
188188
) {
189+
_PyLegacyEventHandler *self = (_PyLegacyEventHandler*)callable;
189190
assert(kwnames == NULL);
190191
assert(PyVectorcall_NARGS(nargsf) == 3);
191192
PyObject *exc = args[2];
@@ -207,39 +208,43 @@ sys_trace_exception_func(
207208

208209
static PyObject *
209210
sys_trace_start(
210-
_PyLegacyEventHandler *self, PyObject *const *args,
211+
PyObject *callable, PyObject *const *args,
211212
size_t nargsf, PyObject *kwnames
212213
) {
214+
_PyLegacyEventHandler *self = (_PyLegacyEventHandler*)callable;
213215
assert(kwnames == NULL);
214216
assert(PyVectorcall_NARGS(nargsf) == 2);
215217
return call_trace_func(self, Py_None);
216218
}
217219

218220
static PyObject *
219221
sys_trace_throw(
220-
_PyLegacyEventHandler *self, PyObject *const *args,
222+
PyObject *callable, PyObject *const *args,
221223
size_t nargsf, PyObject *kwnames
222224
) {
225+
_PyLegacyEventHandler *self = (_PyLegacyEventHandler*)callable;
223226
assert(kwnames == NULL);
224227
assert(PyVectorcall_NARGS(nargsf) == 3);
225228
return call_trace_func(self, Py_None);
226229
}
227230

228231
static PyObject *
229232
sys_trace_unwind(
230-
_PyLegacyEventHandler *self, PyObject *const *args,
233+
PyObject *callable, PyObject *const *args,
231234
size_t nargsf, PyObject *kwnames
232235
) {
236+
_PyLegacyEventHandler *self = (_PyLegacyEventHandler*)callable;
233237
assert(kwnames == NULL);
234238
assert(PyVectorcall_NARGS(nargsf) == 3);
235239
return call_trace_func(self, NULL);
236240
}
237241

238242
static PyObject *
239243
sys_trace_return(
240-
_PyLegacyEventHandler *self, PyObject *const *args,
244+
PyObject *callable, PyObject *const *args,
241245
size_t nargsf, PyObject *kwnames
242246
) {
247+
_PyLegacyEventHandler *self = (_PyLegacyEventHandler*)callable;
243248
assert(!PyErr_Occurred());
244249
assert(kwnames == NULL);
245250
assert(PyVectorcall_NARGS(nargsf) == 3);
@@ -251,19 +256,21 @@ sys_trace_return(
251256

252257
static PyObject *
253258
sys_trace_yield(
254-
_PyLegacyEventHandler *self, PyObject *const *args,
259+
PyObject *callable, PyObject *const *args,
255260
size_t nargsf, PyObject *kwnames
256261
) {
262+
_PyLegacyEventHandler *self = (_PyLegacyEventHandler*)callable;
257263
assert(kwnames == NULL);
258264
assert(PyVectorcall_NARGS(nargsf) == 3);
259265
return call_trace_func(self, args[2]);
260266
}
261267

262268
static PyObject *
263269
sys_trace_instruction_func(
264-
_PyLegacyEventHandler *self, PyObject *const *args,
270+
PyObject *callable, PyObject *const *args,
265271
size_t nargsf, PyObject *kwnames
266272
) {
273+
_PyLegacyEventHandler *self = (_PyLegacyEventHandler*)callable;
267274
assert(kwnames == NULL);
268275
assert(PyVectorcall_NARGS(nargsf) == 2);
269276
PyFrameObject *frame = PyEval_GetFrame();
@@ -313,9 +320,10 @@ trace_line(
313320

314321
static PyObject *
315322
sys_trace_line_func(
316-
_PyLegacyEventHandler *self, PyObject *const *args,
323+
PyObject *callable, PyObject *const *args,
317324
size_t nargsf, PyObject *kwnames
318325
) {
326+
_PyLegacyEventHandler *self = (_PyLegacyEventHandler*)callable;
319327
assert(kwnames == NULL);
320328
PyThreadState *tstate = _PyThreadState_GET();
321329
if (tstate->c_tracefunc == NULL) {
@@ -339,9 +347,10 @@ sys_trace_line_func(
339347
* Handle that case here */
340348
static PyObject *
341349
sys_trace_jump_func(
342-
_PyLegacyEventHandler *self, PyObject *const *args,
350+
PyObject *callable, PyObject *const *args,
343351
size_t nargsf, PyObject *kwnames
344352
) {
353+
_PyLegacyEventHandler *self = (_PyLegacyEventHandler*)callable;
345354
assert(kwnames == NULL);
346355
PyThreadState *tstate = _PyThreadState_GET();
347356
if (tstate->c_tracefunc == NULL) {
@@ -513,48 +522,50 @@ setup_tracing(PyThreadState *tstate, Py_tracefunc func, PyObject *arg, PyObject
513522
if (!tstate->interp->sys_trace_initialized) {
514523
tstate->interp->sys_trace_initialized = true;
515524
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
516-
(vectorcallfunc)sys_trace_start, PyTrace_CALL,
517-
PY_MONITORING_EVENT_PY_START, PY_MONITORING_EVENT_PY_RESUME)) {
525+
sys_trace_start, PyTrace_CALL,
526+
PY_MONITORING_EVENT_PY_START,
527+
PY_MONITORING_EVENT_PY_RESUME)) {
518528
return -1;
519529
}
520530
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
521-
(vectorcallfunc)sys_trace_throw, PyTrace_CALL,
522-
PY_MONITORING_EVENT_PY_THROW, -1)) {
531+
sys_trace_throw, PyTrace_CALL,
532+
PY_MONITORING_EVENT_PY_THROW, -1)) {
523533
return -1;
524534
}
525535
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
526-
(vectorcallfunc)sys_trace_return, PyTrace_RETURN,
527-
PY_MONITORING_EVENT_PY_RETURN, -1)) {
536+
sys_trace_return, PyTrace_RETURN,
537+
PY_MONITORING_EVENT_PY_RETURN, -1)) {
528538
return -1;
529539
}
530540
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
531-
(vectorcallfunc)sys_trace_yield, PyTrace_RETURN,
532-
PY_MONITORING_EVENT_PY_YIELD, -1)) {
541+
sys_trace_yield, PyTrace_RETURN,
542+
PY_MONITORING_EVENT_PY_YIELD, -1)) {
533543
return -1;
534544
}
535545
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
536-
(vectorcallfunc)sys_trace_exception_func, PyTrace_EXCEPTION,
537-
PY_MONITORING_EVENT_RAISE, PY_MONITORING_EVENT_STOP_ITERATION)) {
546+
sys_trace_exception_func, PyTrace_EXCEPTION,
547+
PY_MONITORING_EVENT_RAISE,
548+
PY_MONITORING_EVENT_STOP_ITERATION)) {
538549
return -1;
539550
}
540551
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
541-
(vectorcallfunc)sys_trace_line_func, PyTrace_LINE,
542-
PY_MONITORING_EVENT_LINE, -1)) {
552+
sys_trace_line_func, PyTrace_LINE,
553+
PY_MONITORING_EVENT_LINE, -1)) {
543554
return -1;
544555
}
545556
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
546-
(vectorcallfunc)sys_trace_unwind, PyTrace_RETURN,
547-
PY_MONITORING_EVENT_PY_UNWIND, -1)) {
557+
sys_trace_unwind, PyTrace_RETURN,
558+
PY_MONITORING_EVENT_PY_UNWIND, -1)) {
548559
return -1;
549560
}
550561
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
551-
(vectorcallfunc)sys_trace_jump_func, PyTrace_LINE,
552-
PY_MONITORING_EVENT_JUMP, -1)) {
562+
sys_trace_jump_func, PyTrace_LINE,
563+
PY_MONITORING_EVENT_JUMP, -1)) {
553564
return -1;
554565
}
555566
if (set_callbacks(PY_MONITORING_SYS_TRACE_ID,
556-
(vectorcallfunc)sys_trace_instruction_func, PyTrace_OPCODE,
557-
PY_MONITORING_EVENT_INSTRUCTION, -1)) {
567+
sys_trace_instruction_func, PyTrace_OPCODE,
568+
PY_MONITORING_EVENT_INSTRUCTION, -1)) {
558569
return -1;
559570
}
560571
}

0 commit comments

Comments
 (0)