https://github.com/python/cpython/commit/1ab8862ea0ad8d52af8a75866077b1e09b0ba62d
commit: 1ab8862ea0ad8d52af8a75866077b1e09b0ba62d
branch: main
author: Prakash Sellathurai <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2026-06-22T16:41:31+05:30
summary:

gh-151905: fix memory error handling in PyFrame_GetBack (#151906)

files:
A 
Misc/NEWS.d/next/Core_and_Builtins/2026-06-22-06-26-34.gh-issue-151905.FOLMYg.rst
M Objects/frameobject.c

diff --git 
a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-22-06-26-34.gh-issue-151905.FOLMYg.rst
 
b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-22-06-26-34.gh-issue-151905.FOLMYg.rst
new file mode 100644
index 00000000000000..c71122df6b8580
--- /dev/null
+++ 
b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-22-06-26-34.gh-issue-151905.FOLMYg.rst
@@ -0,0 +1 @@
+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 b19889d3034e71..e7ac59379dcfbc 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -1114,7 +1114,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;
@@ -2402,6 +2402,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