[3.13] gh-151905: fix memory error handling in PyFrame_GetBack
(pythonGH-151906)
Signed-off-by: Prakash Sellathurai <prakashsellathurai@gmail.com>
--- /dev/null
+Fix OOM error handling in :c:func:`PyFrame_GetBack` to propagate exceptions
+instead of masking them as None.
frame_getback(PyFrameObject *f, void *closure)
{
PyObject *res = (PyObject *)PyFrame_GetBack(f);
- if (res == NULL) {
+ if (res == NULL && !PyErr_Occurred()) {
Py_RETURN_NONE;
}
return res;
prev = _PyFrame_GetFirstComplete(prev);
if (prev) {
back = _PyFrame_GetFrameObject(prev);
+ if (back == NULL) {
+ return NULL;
+ }
}
}
return (PyFrameObject*)Py_XNewRef(back);