mirror of
https://github.com/python/cpython.git
synced 2025-08-29 21:25:01 +00:00
GH-101578: Normalize the current exception (GH-101607)
* Make sure that the current exception is always normalized. * Remove redundant type and traceback fields for the current exception. * Add new API functions: PyErr_GetRaisedException, PyErr_SetRaisedException * Add new API functions: PyException_GetArgs, PyException_SetArgs
This commit is contained in:
parent
027adf42cd
commit
feec49c407
29 changed files with 477 additions and 172 deletions
|
@ -1592,6 +1592,13 @@ remove_importlib_frames(PyThreadState *tstate)
|
|||
Py_DECREF(code);
|
||||
tb = next;
|
||||
}
|
||||
assert(PyExceptionInstance_Check(value));
|
||||
assert((PyObject *)Py_TYPE(value) == exception);
|
||||
if (base_tb == NULL) {
|
||||
base_tb = Py_None;
|
||||
Py_INCREF(Py_None);
|
||||
}
|
||||
PyException_SetTraceback(value, base_tb);
|
||||
done:
|
||||
_PyErr_Restore(tstate, exception, value, base_tb);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue