Skip to content

Commit 2109f78

Browse files
authored
bpo-45711: Remove unnecessary normalization of exc_info (GH-29922)
1 parent 7778116 commit 2109f78

File tree

2 files changed

+1
-20
lines changed

2 files changed

+1
-20
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:c:func:`_PyErr_ChainStackItem` no longer normalizes ``exc_info`` (including setting the traceback on the exception instance) because ``exc_info`` is always normalized.

Python/errors.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -647,26 +647,6 @@ _PyErr_ChainStackItem(_PyErr_StackItem *exc_info)
647647
PyObject *typ, *val, *tb;
648648
_PyErr_Fetch(tstate, &typ, &val, &tb);
649649

650-
PyObject *typ2, *val2, *tb2;
651-
typ2 = exc_info->exc_type;
652-
val2 = exc_info->exc_value;
653-
tb2 = exc_info->exc_traceback;
654-
#ifdef Py_DEBUG
655-
PyObject *typ2_before = typ2;
656-
PyObject *val2_before = val2;
657-
PyObject *tb2_before = tb2;
658-
#endif
659-
_PyErr_NormalizeException(tstate, &typ2, &val2, &tb2);
660-
#ifdef Py_DEBUG
661-
/* exc_info should already be normalized */
662-
assert(typ2 == typ2_before);
663-
assert(val2 == val2_before);
664-
assert(tb2 == tb2_before);
665-
#endif
666-
if (tb2 != NULL) {
667-
PyException_SetTraceback(val2, tb2);
668-
}
669-
670650
/* _PyErr_SetObject sets the context from PyThreadState. */
671651
_PyErr_SetObject(tstate, typ, val);
672652
Py_DECREF(typ); // since _PyErr_Occurred was true

0 commit comments

Comments
 (0)