summaryrefslogtreecommitdiffstats
path: root/Python/traceback.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-05-22 23:00:58 (GMT)
committerGitHub <noreply@github.com>2019-05-22 23:00:58 (GMT)
commitdf22c03b93ea4620fdf4a0b3cbbbfa7c645af783 (patch)
tree87a86340ef143d19350e9f52b18d4f28f0a982b7 /Python/traceback.c
parent5edcf263581c70f6a6c2206db679e51e9418bb38 (diff)
downloadcpython-df22c03b93ea4620fdf4a0b3cbbbfa7c645af783.zip
cpython-df22c03b93ea4620fdf4a0b3cbbbfa7c645af783.tar.gz
cpython-df22c03b93ea4620fdf4a0b3cbbbfa7c645af783.tar.bz2
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.
Diffstat (limited to 'Python/traceback.c')
-rw-r--r--Python/traceback.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/Python/traceback.c b/Python/traceback.c
index 18bd0bf..04b52ad 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -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;