GH-102818: Do not call `PyTraceBack_Here` in sys.settrace trampoline. by markshannon · Pull Request #104579 · python/cpython
static int error_func(PyObject *obj, PyFrameObject *f, int what, PyObject *arg) { assert(PyList_Check(obj)); /* Only raise if list is empty, otherwise append None * This ensures that we only raise once */ if (PyList_GET_SIZE(obj)) { return 0; } if (PyList_Append(obj, Py_None)) { return -1; } PyErr_SetString(PyExc_Exception, "an exception"); return -1; }
static PyObject * settrace_to_error(PyObject *self, PyObject *list) { if (!PyList_Check(list)) { PyErr_SetString(PyExc_TypeError, "argument must be a list"); return NULL; } PyEval_SetTrace(error_func, list); Py_RETURN_NONE; }
static PyObject * clear_managed_dict(PyObject *self, PyObject *obj) {