From fd7463aae1a6b96b23f9c8a934e5776a8bfe9a39 Mon Sep 17 00:00:00 2001 From: grantlouisherman Date: Thu, 21 May 2026 21:12:03 -0400 Subject: [PATCH 1/3] type-crash(): make helpers.c in tokenizer throw a no mem error when malloc fails Signed-off-by: grantlouisherman --- Parser/tokenizer/helpers.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Parser/tokenizer/helpers.c b/Parser/tokenizer/helpers.c index 9542969ad3127b..32064909ebba01 100644 --- a/Parser/tokenizer/helpers.c +++ b/Parser/tokenizer/helpers.c @@ -221,6 +221,7 @@ _PyTokenizer_translate_newlines(const char *s, int exec_input, int preserve_crlf buf = PyMem_Malloc(needed_length); if (buf == NULL) { tok->done = E_NOMEM; + PyErr_NoMemory(); return NULL; } for (current = buf; *s; s++, current++) { From f3da2688801745b2603bbf3b84eb6153842d627d Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Fri, 22 May 2026 01:18:03 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Library/2026-05-22-01-18-01.gh-issue-150207.je1B0Y.rst | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2026-05-22-01-18-01.gh-issue-150207.je1B0Y.rst diff --git a/Misc/NEWS.d/next/Library/2026-05-22-01-18-01.gh-issue-150207.je1B0Y.rst b/Misc/NEWS.d/next/Library/2026-05-22-01-18-01.gh-issue-150207.je1B0Y.rst new file mode 100644 index 00000000000000..d6ba99c5694781 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-05-22-01-18-01.gh-issue-150207.je1B0Y.rst @@ -0,0 +1,4 @@ +Set a :exc:`MemoryError` via :c:func:`PyErr_NoMemory` when buffer allocation + fails in the tokenizer's ``_PyTokenizer_translate_newlines`` helper, so the + out-of-memory condition is propagated as a proper Python exception instead + of only being recorded in ``tok->done``. From 736e8d4924a4e7f29927996a68e306c1724d7770 Mon Sep 17 00:00:00 2001 From: grantlouisherman Date: Thu, 21 May 2026 21:23:04 -0400 Subject: [PATCH 3/3] lint blurb Signed-off-by: grantlouisherman --- .../Library/2026-05-22-01-18-01.gh-issue-150207.je1B0Y.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2026-05-22-01-18-01.gh-issue-150207.je1B0Y.rst b/Misc/NEWS.d/next/Library/2026-05-22-01-18-01.gh-issue-150207.je1B0Y.rst index d6ba99c5694781..ebf57db806f62c 100644 --- a/Misc/NEWS.d/next/Library/2026-05-22-01-18-01.gh-issue-150207.je1B0Y.rst +++ b/Misc/NEWS.d/next/Library/2026-05-22-01-18-01.gh-issue-150207.je1B0Y.rst @@ -1,4 +1,4 @@ -Set a :exc:`MemoryError` via :c:func:`PyErr_NoMemory` when buffer allocation - fails in the tokenizer's ``_PyTokenizer_translate_newlines`` helper, so the - out-of-memory condition is propagated as a proper Python exception instead +Set a :exc:`MemoryError` via :c:func:`PyErr_NoMemory` when buffer allocation + fails in the tokenizer's ``_PyTokenizer_translate_newlines`` helper, so the + out-of-memory condition is propagated as a proper Python exception instead of only being recorded in ``tok->done``.