]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-151126: Add missing `PyErr_NoMemory` in `_winapi` module (#151154)
authorsobolevn <mail@sobolevn.me>
Tue, 9 Jun 2026 16:42:08 +0000 (19:42 +0300)
committerGitHub <noreply@github.com>
Tue, 9 Jun 2026 16:42:08 +0000 (19:42 +0300)
Misc/NEWS.d/next/Core_and_Builtins/2026-06-09-10-28-30.gh-issue-151126.DKa6Sl.rst
Modules/_winapi.c

index 3f699a50d7a42bb20efb76d98e492190443e4111..81e87e539865ce3de11ecb6ccb15d2b6f732d458 100644 (file)
@@ -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.
index fc2c0890468a6b96ba43212299836491eab60b77..369a7400eb63b90aa93bf8e76838d347a7606330 100644 (file)
@@ -1194,8 +1194,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));
@@ -1278,6 +1280,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;
     }