[3.15] gh-151905: fix memory error handling in PyFrame_GetBack (GH-151906) (#151919)

Co-authored-by: Prakash Sellathurai <prakashsellathurai@gmail.com>
This commit is contained in:
Miss Islington (bot) 2026-06-23 08:28:59 +02:00 committed by GitHub
parent 752e23ec90
commit fe5dc86f1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View file

@ -0,0 +1 @@
Fix OOM error handling in :c:func:`PyFrame_GetBack` to propagate exceptions instead of masking them as None.

View file

@ -1117,7 +1117,7 @@ frame_back_get_impl(PyFrameObject *self)
/*[clinic end generated code: output=3a84c22a55a63c79 input=9e528570d0e1f44a]*/
{
PyObject *res = (PyObject *)PyFrame_GetBack(self);
if (res == NULL) {
if (res == NULL && !PyErr_Occurred()) {
Py_RETURN_NONE;
}
return res;
@ -2405,6 +2405,9 @@ PyFrame_GetBack(PyFrameObject *frame)
prev = _PyFrame_GetFirstComplete(prev);
if (prev) {
back = _PyFrame_GetFrameObject(prev);
if (back == NULL) {
return NULL;
}
}
}
return (PyFrameObject*)Py_XNewRef(back);