https://github.com/python/cpython/commit/22830103e598c63663b462c4e42b74e7a9d3bb99 commit: 22830103e598c63663b462c4e42b74e7a9d3bb99 branch: main author: Alper <alper_yo...@hotmail.com> committer: mpage <mp...@cs.stanford.edu> date: 2025-04-17T13:38:34-07:00 summary:
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 <alperyo...@fb.com> files: M Python/frame.c diff --git a/Python/frame.c b/Python/frame.c index 558f92055bbfc1..ce216797e47cda 100644 --- a/Python/frame.c +++ b/Python/frame.c @@ -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); _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com