mirror of
https://github.com/python/cpython.git
synced 2025-07-07 11:25:30 +00:00
gh-131173: Improve exception handling during take_ownership processing (#132620)
Save and restore exceptions during take_ownership processing to preserve exceptions currently being raised. Co-authored-by: alperyoney <alperyoney@fb.com>
This commit is contained in:
parent
1d529cbc89
commit
22830103e5
1 changed files with 2 additions and 0 deletions
|
@ -69,6 +69,7 @@ take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame)
|
|||
_PyInterpreterFrame *prev = _PyFrame_GetFirstComplete(frame->previous);
|
||||
if (prev) {
|
||||
assert(prev->owner < FRAME_OWNED_BY_INTERPRETER);
|
||||
PyObject *exc = PyErr_GetRaisedException();
|
||||
/* Link PyFrameObjects.f_back and remove link through _PyInterpreterFrame.previous */
|
||||
PyFrameObject *back = _PyFrame_GetFrameObject(prev);
|
||||
if (back == NULL) {
|
||||
|
@ -80,6 +81,7 @@ take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame)
|
|||
else {
|
||||
f->f_back = (PyFrameObject *)Py_NewRef(back);
|
||||
}
|
||||
PyErr_SetRaisedException(exc);
|
||||
}
|
||||
if (!_PyObject_GC_IS_TRACKED((PyObject *)f)) {
|
||||
_PyObject_GC_TRACK((PyObject *)f);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue