mirror of
https://github.com/python/cpython.git
synced 2026-02-14 19:31:08 +00:00
bpo-36829: PyErr_WriteUnraisable() normalizes exception (GH-13507)
PyErr_WriteUnraisable() now creates a traceback object if there is no current traceback. Moreover, call PyErr_NormalizeException() and PyException_SetTraceback() to normalize the exception value. Ignore silently any error.
This commit is contained in:
parent
5edcf26358
commit
df22c03b93
5 changed files with 47 additions and 13 deletions
|
|
@ -227,13 +227,24 @@ PyTypeObject PyTraceBack_Type = {
|
|||
tb_new, /* tp_new */
|
||||
};
|
||||
|
||||
|
||||
PyObject*
|
||||
_PyTraceBack_FromFrame(PyObject *tb_next, PyFrameObject *frame)
|
||||
{
|
||||
assert(tb_next == NULL || PyTraceBack_Check(tb_next));
|
||||
assert(frame != NULL);
|
||||
|
||||
return tb_create_raw((PyTracebackObject *)tb_next, frame, frame->f_lasti,
|
||||
PyFrame_GetLineNumber(frame));
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
PyTraceBack_Here(PyFrameObject *frame)
|
||||
{
|
||||
PyObject *exc, *val, *tb, *newtb;
|
||||
PyErr_Fetch(&exc, &val, &tb);
|
||||
newtb = tb_create_raw((PyTracebackObject *)tb, frame, frame->f_lasti,
|
||||
PyFrame_GetLineNumber(frame));
|
||||
newtb = _PyTraceBack_FromFrame(tb, frame);
|
||||
if (newtb == NULL) {
|
||||
_PyErr_ChainExceptions(exc, val, tb);
|
||||
return -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue