Kaydet (Commit) 3bafbf3a authored tarafından Batuhan Taşkaya's avatar Batuhan Taşkaya

settrace/setprofile function gets lost

üst f665b96e
......@@ -31,6 +31,7 @@ PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,
#ifndef Py_LIMITED_API
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
PyAPI_FUNC(void) PyEval_TempResetSetTrace();
PyAPI_FUNC(void) _PyEval_SetCoroutineOriginTrackingDepth(int new_depth);
PyAPI_FUNC(int) _PyEval_GetCoroutineOriginTrackingDepth(void);
PyAPI_FUNC(void) _PyEval_SetCoroutineWrapper(PyObject *);
......
......@@ -486,6 +486,7 @@ class RaisingTraceFuncTestCase(unittest.TestCase):
if event == self.raiseOnEvent:
raise ValueError # just something that isn't RuntimeError
else:
print(1)
return self.trace
def f(self):
......
......@@ -4589,6 +4589,18 @@ PyEval_SetTrace(Py_tracefunc func, PyObject *arg)
|| (tstate->c_profilefunc != NULL));
}
void
PyEval_TempResetSetTrace()
{
_PyRuntimeState *runtime = &_PyRuntime;
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
Py_tracefunc tracefunc = tstate->c_tracefunc;
PyObject *traceobj = tstate->c_traceobj;
Py_XINCREF(traceobj);
PyEval_SetTrace(NULL, NULL);
PyEval_SetTrace(tracefunc, traceobj);
}
void
_PyEval_SetCoroutineOriginTrackingDepth(int new_depth)
{
......
......@@ -558,7 +558,7 @@ trace_trampoline(PyObject *self, PyFrameObject *frame,
return 0;
result = call_trampoline(callback, frame, what, arg);
if (result == NULL) {
PyEval_SetTrace(NULL, NULL);
PyEval_TempResetSetTrace();
Py_CLEAR(frame->f_trace);
return -1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment