https://github.com/python/cpython/commit/83bea6487cdb65b4d1403dc7a29330b0d7bc45e9
commit: 83bea6487cdb65b4d1403dc7a29330b0d7bc45e9
branch: main
author: Pengyu Lee <[email protected]>
committer: pablogsal <[email protected]>
date: 2026-09-28T12:52:26+01:00
summary:

gh-158309: Set MemoryError when allocation fails in  
`decode_unicode_with_escapes()` (#158311)

files:
M Parser/string_parser.c

diff --git a/Parser/string_parser.c b/Parser/string_parser.c
index 20f523a262b225a..5df7ae8bec04b25 100644
--- a/Parser/string_parser.c
+++ b/Parser/string_parser.c
@@ -147,7 +147,7 @@ decode_unicode_with_escapes(Parser *parser, const char *s, 
size_t len, Token *t)
     Py_ssize_t alloc = (Py_ssize_t)len * 6;
     char *buf = PyMem_Malloc(alloc);
     if (buf == NULL) {
-        return NULL;
+        return PyErr_NoMemory();
     }
     p = buf;
     end = s + len;

_______________________________________________
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