diff options
| author | Alper <alper_yoney@hotmail.com> | 2025-04-17 20:38:34 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-17 20:38:34 (GMT) |
| commit | 22830103e598c63663b462c4e42b74e7a9d3bb99 (patch) | |
| tree | 3fc56f236efb317e309efdfe961e94247786ecf3 /Python | |
| parent | 1d529cbc892b824b387d672899265ed4258b2222 (diff) | |
| download | cpython-22830103e598c63663b462c4e42b74e7a9d3bb99.zip cpython-22830103e598c63663b462c4e42b74e7a9d3bb99.tar.gz cpython-22830103e598c63663b462c4e42b74e7a9d3bb99.tar.bz2 | |
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>
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/frame.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Python/frame.c b/Python/frame.c index 558f920..ce21679 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); |
