Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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``.
Comment on lines +2 to +4
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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``.
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``.

1 change: 1 addition & 0 deletions Parser/tokenizer/helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
Loading