Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
597c294
Use diagnostic line for missing-brace errors
pablogsal Sep 24, 2026
9df1aa0
Keep implicit prepared newline metadata in the reader
pablogsal Sep 24, 2026
578b0c5
Reuse parsed formatted string kind in lexer
pablogsal Sep 24, 2026
072439a
Transfer owned tokenizer encoding strings
pablogsal Sep 24, 2026
29f8d4a
Remove unused tokenizer state and redundant branches
pablogsal Sep 24, 2026
c911eb4
Avoid rescanning partial decoded tokenizer lines
pablogsal Sep 24, 2026
f0149a8
Reuse prepared tokenizer line terminators for CR detection
pablogsal Sep 24, 2026
c5465b3
Reuse interactive tokenizer chunks without carriage returns
pablogsal Sep 24, 2026
02764ba
Release tokenizer constructor resources on allocation failure
pablogsal Sep 24, 2026
c04c0bb
Narrow interactive newline normalization wrapper
pablogsal Sep 24, 2026
b44bde7
Close duplicated tokenizer descriptors when fdopen fails
pablogsal Sep 24, 2026
1e44edc
Preserve cached tokenizer lines when newline allocation fails
pablogsal Sep 24, 2026
f995e1a
Collect cycles involving tokenizer readline callbacks
pablogsal Sep 24, 2026
6e43c27
Preserve buffered text when decoding source files
pablogsal Sep 24, 2026
a36c95c
Clear the transferred syntax error line before cleanup
pablogsal Sep 24, 2026
ffd9ac3
Propagate tokenizer column conversion failures
pablogsal Sep 24, 2026
6fefac8
Allocate parser repetition buffers on first match
pablogsal Sep 24, 2026
cc4ae2a
Allocate type comment storage only when needed
pablogsal Sep 24, 2026
fca5aac
Reuse decoded multiline text when counting token columns
pablogsal Sep 24, 2026
98ced0a
Skip empty decoded tokenizer chunks
pablogsal Sep 24, 2026
b8eba43
Check parser array growth before allocating
pablogsal Sep 24, 2026
a29e2fd
Name tokenizer bounds and derive byte lengths from their data
pablogsal Sep 24, 2026
3587fb1
Set the tokenizer exception when file input size overflows
pablogsal Sep 24, 2026
39f6d4c
gh-153569: Send exact line endings in the REPL test
pablogsal Sep 24, 2026
ba72635
Share parser repetition buffer growth
pablogsal Sep 24, 2026
a768c1d
Fold Unicode input coverage into the existing REPL test
pablogsal Sep 24, 2026
7264275
Keep parser array growth policy private
pablogsal Sep 24, 2026
e55d8b0
Drop obsolete bitmap stress from source discard test
pablogsal Sep 24, 2026
714d6dd
Preserve input failures while scanning string literals
pablogsal Sep 25, 2026
657d92c
fixup! Preserve input failures while scanning string literals
pablogsal Sep 28, 2026
39436f7
fixup! fixup! Preserve input failures while scanning string literals
pablogsal Sep 29, 2026
452e6fa
gh-153569: Remove assertion-only lexer bookkeeping
pablogsal Sep 29, 2026
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
Prev Previous commit
Next Next commit
Allocate type comment storage only when needed
  • Loading branch information
pablogsal committed Sep 29, 2026
commit cc4ae2a791d939599bc94db09e4c97a9810c367e
20 changes: 3 additions & 17 deletions Parser/pegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,10 @@ init_normalization(Parser *p)
return 1;
}

static int
growable_comment_array_init(growable_comment_array *arr, size_t initial_size) {
assert(initial_size > 0);
arr->items = PyMem_Malloc(initial_size * sizeof(*arr->items));
arr->size = initial_size;
arr->num_items = 0;

return arr->items != NULL;
}

static int
growable_comment_array_add(growable_comment_array *arr, int lineno, char *comment) {
if (arr->num_items >= arr->size) {
size_t new_size = arr->size * 2;
size_t new_size = arr->size ? arr->size * 2 : 10;
void *new_items_array = PyMem_Realloc(arr->items, new_size * sizeof(*arr->items));
if (!new_items_array) {
return 0;
Expand Down Expand Up @@ -324,6 +314,7 @@ _PyPegen_fill_token(Parser *p)
tag[len] = '\0';
// Ownership of tag passes to the growable array
if (!growable_comment_array_add(&p->type_ignore_comments, new_token.end_loc.lineno, tag)) {
PyMem_Free(tag);
PyErr_NoMemory();
goto error;
}
Expand Down Expand Up @@ -947,12 +938,7 @@ _PyPegen_Parser_New(struct tok_state *tok, int start_rule, int flags,
PyMem_Free(p);
return (Parser *) PyErr_NoMemory();
}
if (!growable_comment_array_init(&p->type_ignore_comments, 10)) {
PyMem_Free(p->tokens[0]);
PyMem_Free(p->tokens);
PyMem_Free(p);
return (Parser *) PyErr_NoMemory();
}
p->type_ignore_comments = (growable_comment_array){0};

p->mark = 0;
p->fill = 0;
Expand Down