https://github.com/python/cpython/commit/4448205d95e87ca3d1e23cc350af59ec48b3321b
commit: 4448205d95e87ca3d1e23cc350af59ec48b3321b
branch: main
author: Ivy Xu <[email protected]>
committer: FFY00 <[email protected]>
date: 2026-06-22T14:59:22+01:00
summary:

gh-151126: Fix missing `PyErr_NoMemory` in `getpath.c` (#151590)

files:
A 
Misc/NEWS.d/next/Core_and_Builtins/2026-06-17-16-26-45.gh-issue-151126.Yc_6wC.rst
M Modules/getpath.c

diff --git 
a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-17-16-26-45.gh-issue-151126.Yc_6wC.rst
 
b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-17-16-26-45.gh-issue-151126.Yc_6wC.rst
new file mode 100644
index 00000000000000..29bb03d2d40859
--- /dev/null
+++ 
b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-17-16-26-45.gh-issue-151126.Yc_6wC.rst
@@ -0,0 +1,2 @@
+Avoid possible crash in ``getpath.c`` where a device has no memory left. Now
+it properly raises a :exc:`MemoryError`. Patch by Ivy Xu.
diff --git a/Modules/getpath.c b/Modules/getpath.c
index 1e75993480ae36..0c80678a678dc8 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -368,6 +368,7 @@ getpath_readlines(PyObject *Py_UNUSED(self), PyObject *args)
     if (!buffer) {
         Py_DECREF(r);
         fclose(fp);
+        PyErr_NoMemory();
         return NULL;
     }
 

_______________________________________________
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