https://github.com/python/cpython/commit/117b76a19078e5454f2530e91cae5646eec7502c
commit: 117b76a19078e5454f2530e91cae5646eec7502c
branch: 3.13
author: Prakash Sellathurai <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2026-06-24T11:40:07Z
summary:

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

[3.13] gh-151905: fix memory error handling in PyFrame_GetBack
(pythonGH-151906)

Signed-off-by: Prakash Sellathurai <[email protected]>

files:
A 
Misc/NEWS.d/next/Core_and_Builtins/2026-06-24-11-12-56.gh-issue-151905.j32skf.rst
M Objects/frameobject.c

diff --git 
a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-24-11-12-56.gh-issue-151905.j32skf.rst
 
b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-24-11-12-56.gh-issue-151905.j32skf.rst
new file mode 100644
index 000000000000000..c02145233d0e824
--- /dev/null
+++ 
b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-24-11-12-56.gh-issue-151905.j32skf.rst
@@ -0,0 +1,2 @@
+Fix OOM error handling in :c:func:`PyFrame_GetBack` to propagate exceptions
+instead of masking them as None.
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 467c3fe56e98f20..9d26a3cdeed4e7d 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -963,7 +963,7 @@ static PyObject *
 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;
@@ -2203,6 +2203,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);

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to