mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.13] gh-128799: Add frame of except* to traceback when wrapping a naked exception (#128971) (#129299)
This commit is contained in:
parent
fcb265671c
commit
a853e2f076
3 changed files with 40 additions and 0 deletions
|
@ -27,6 +27,7 @@
|
|||
#include "pycore_setobject.h" // _PySet_Update()
|
||||
#include "pycore_sliceobject.h" // _PyBuildSlice_ConsumeRefs
|
||||
#include "pycore_sysmodule.h" // _PySys_Audit()
|
||||
#include "pycore_traceback.h" // _PyTraceBack_FromFrame
|
||||
#include "pycore_tuple.h" // _PyTuple_ITEMS()
|
||||
#include "pycore_typeobject.h" // _PySuper_Lookup()
|
||||
#include "pycore_uop_ids.h" // Uops
|
||||
|
@ -2018,6 +2019,17 @@ _PyEval_ExceptionGroupMatch(PyObject* exc_value, PyObject *match_type,
|
|||
if (wrapped == NULL) {
|
||||
return -1;
|
||||
}
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
_PyInterpreterFrame *frame = _PyThreadState_GetFrame(tstate);
|
||||
PyFrameObject *f = _PyFrame_GetFrameObject(frame);
|
||||
if (f != NULL) {
|
||||
PyObject *tb = _PyTraceBack_FromFrame(NULL, f);
|
||||
if (tb == NULL) {
|
||||
return -1;
|
||||
}
|
||||
PyException_SetTraceback(wrapped, tb);
|
||||
Py_DECREF(tb);
|
||||
}
|
||||
*match = wrapped;
|
||||
}
|
||||
*rest = Py_NewRef(Py_None);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue