Fix three crashes in the parser - #81
Open
hilman2 wants to merge 1 commit into
Open
Conversation
`transformToken` uppercased the whole string literal before evaluating it. That turns a newline escape into `\N`, an invalid escape, so every `c'...'` string containing a backslash aborted compilation. The result is only tested for emptiness, so the call had no purpose. The same method returned `None` for an empty string. Callers append the result unconditionally, so `c''` crashed with a TypeError. `_eatSingleLineDef` bound `useSearchList_orig` in the closure branch only but read it whenever `isNestedDef` was true. A single-line `#block` inside a `#def` takes the other branch with `isNestedDef` true, so it raised UnboundLocalError. The restore now follows the same condition as the assignment. Escapes inside `c'...'` strings stay uninterpreted; the string is read character by character from the source. This only stops the crash. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three templates that abort compilation on master:
The first two come from
transformToken: it uppercases the whole string literal beforeeval, and it returnsNonewhen the string is empty. The uppercased value is only tested for emptiness, so the call has no purpose.The third is
_eatSingleLineDefbindinguseSearchList_origin one branch and reading it under a different condition.Escapes inside
c'...'stay uninterpreted, since the string is read character by character from the source. This only stops the crash.Three regression tests in
SyntaxAndOutput.py. Full suite passes on 2.7, 3.6 and 3.12, flake8 clean.