Skip to content

馃悰 Fix RecursionError on long runs of consecutive newlines - #601

Merged
MiWeiss merged 4 commits into
mainfrom
fix/splitter-recursion
Sep 2, 2026
Merged

MiWeiss merged 4 commits into
mainfrom
fix/splitter-recursion

Conversation

@MiWeiss

@MiWeiss MiWeiss commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator

Splitter._next_mark skips newline marks by recursing, one stack frame per newline.

>>> bibtexparser.parse_string("\n" * 1000 + "@article{a, title={x}}")
RecursionError

Hits any file with ~1000+ consecutive lines free of { } " , =. Inside a braced value the error escapes to the caller instead of becoming a failed block.

Fix: loop instead of recurse. Line counting and EOF handling unchanged.

Tests: 6 cases at 3000 newlines, all fail before. Suite 2582 passed, from 2576.


馃 Generated with Claude Code

@MiWeiss
MiWeiss force-pushed the fix/splitter-recursion branch 3 times, most recently from 0b65dcb to 6459e48 Compare September 2, 2026 20:00
`Splitter._next_mark` skipped newline marks by calling itself
recursively, burning one stack frame per consecutive newline. Files with
~1000 or more consecutive lines containing none of `{`, `}`, `"`, `,`,
`=` therefore raised a `RecursionError` instead of parsing (or, inside a
braced value, aborted parsing with a "please report this bug" message).

Newlines are now skipped in an iterative loop, keeping the line counting,
char-index and EOF bookkeeping unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@MiWeiss
MiWeiss force-pushed the fix/splitter-recursion branch from 6459e48 to 56b7f7a Compare September 2, 2026 20:03
Comment thread bibtexparser/splitter.py Outdated
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@MiWeiss

MiWeiss commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator Author

lgtm

@MiWeiss
MiWeiss force-pushed the fix/splitter-recursion branch from 6ede972 to d79afd3 Compare September 2, 2026 20:38
@MiWeiss
MiWeiss merged commit f4db076 into main Sep 2, 2026
16 checks passed
@MiWeiss
MiWeiss deleted the fix/splitter-recursion branch September 10, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant