settrace/setprofile function gets lost · isidentical/cpython@3bafbf3 (original) (raw)
4 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -31,6 +31,7 @@ PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj, | ||
31 | 31 | #ifndef Py_LIMITED_API |
32 | 32 | PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *); |
33 | 33 | PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *); |
34 | +PyAPI_FUNC(void) PyEval_TempResetSetTrace(); | |
34 | 35 | PyAPI_FUNC(void) _PyEval_SetCoroutineOriginTrackingDepth(int new_depth); |
35 | 36 | PyAPI_FUNC(int) _PyEval_GetCoroutineOriginTrackingDepth(void); |
36 | 37 | PyAPI_FUNC(void) _PyEval_SetCoroutineWrapper(PyObject *); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -486,6 +486,7 @@ def trace(self, frame, event, arg): | ||
486 | 486 | if event == self.raiseOnEvent: |
487 | 487 | raise ValueError # just something that isn't RuntimeError |
488 | 488 | else: |
489 | +print(1) | |
489 | 490 | return self.trace |
490 | 491 | |
491 | 492 | def f(self): |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4589,6 +4589,18 @@ PyEval_SetTrace(Py_tracefunc func, PyObject *arg) | ||
4589 | 4589 | | |
4590 | 4590 | } |
4591 | 4591 | |
4592 | +void | |
4593 | +PyEval_TempResetSetTrace() | |
4594 | +{ | |
4595 | +_PyRuntimeState *runtime = &_PyRuntime; | |
4596 | +PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime); | |
4597 | +Py_tracefunc tracefunc = tstate->c_tracefunc; | |
4598 | +PyObject *traceobj = tstate->c_traceobj; | |
4599 | +Py_XINCREF(traceobj); | |
4600 | +PyEval_SetTrace(NULL, NULL); | |
4601 | +PyEval_SetTrace(tracefunc, traceobj); | |
4602 | +} | |
4603 | + | |
4592 | 4604 | void |
4593 | 4605 | _PyEval_SetCoroutineOriginTrackingDepth(int new_depth) |
4594 | 4606 | { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -558,7 +558,7 @@ trace_trampoline(PyObject *self, PyFrameObject *frame, | ||
558 | 558 | return 0; |
559 | 559 | result = call_trampoline(callback, frame, what, arg); |
560 | 560 | if (result == NULL) { |
561 | -PyEval_SetTrace(NULL, NULL); | |
561 | +PyEval_TempResetSetTrace(); | |
562 | 562 | Py_CLEAR(frame->f_trace); |
563 | 563 | return -1; |
564 | 564 | } |