https://github.com/python/cpython/commit/489d6af9af5318c949e7311f343288ae2beda960
commit: 489d6af9af5318c949e7311f343288ae2beda960
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: sobolevn <[email protected]>
date: 2026-06-09T17:10:18Z
summary:

[3.15] gh-151126: Add missing `PyErr_NoMemory` in `_winapi` module (GH-151154) 
(#151180)

gh-151126: Add missing `PyErr_NoMemory` in `_winapi` module (GH-151154)
(cherry picked from commit 8d94fa7b8696db6a7942f8a4b930289e69e9b174)

Co-authored-by: sobolevn <[email protected]>

files:
M 
Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst
M Modules/_winapi.c

diff --git 
a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst
 
b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst
index 3f699a50d7a42b..81e87e539865ce 100644
--- 
a/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst
+++ 
b/Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst
@@ -1,3 +1,7 @@
 Fix a crash, when there's no memory left on a device,
-which happened in code compilation.
-Now it raises a proper :exc:`MemoryError`.
+which happened in:
+
+- code compilation
+- :func:`!_winapi.CreateProcess`
+
+Now these places raise proper :exc:`MemoryError` errors.
diff --git a/Modules/_winapi.c b/Modules/_winapi.c
index ffa407b2f21f73..74644a57eb9d47 100644
--- a/Modules/_winapi.c
+++ b/Modules/_winapi.c
@@ -1187,8 +1187,10 @@ gethandlelist(PyObject *mapping, const char *name, 
Py_ssize_t *size)
     }
 
     ret = PyMem_Malloc(*size);
-    if (ret == NULL)
+    if (ret == NULL) {
+        PyErr_NoMemory();
         goto cleanup;
+    }
 
     for (i = 0; i < PySequence_Fast_GET_SIZE(value_fast); i++) {
         ret[i] = PYNUM_TO_HANDLE(PySequence_Fast_GET_ITEM(value_fast, i));
@@ -1271,6 +1273,7 @@ getattributelist(PyObject *obj, const char *name, 
AttributeList *attribute_list)
     attribute_list->attribute_list = PyMem_Malloc(attribute_list_size);
     if (attribute_list->attribute_list == NULL) {
         ret = -1;
+        PyErr_NoMemory();
         goto cleanup;
     }
 

_______________________________________________
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