Report two compiler errors instead of crashing - #82
Open
hilman2 wants to merge 1 commit into
Open
Conversation
`raise ParseError(self, ...)` passes the compiler where ParseError expects a stream and calls stream.pos() on it. In ModuleCompiler.__init__ that happens before _setupCompilerState(), so __getattr__ recurses on the missing _activeClassesList and `#unicode` together with `#encoding` ends in RecursionError. ClassCompiler.addAttribute has the same defect and dies with AttributeError: pos. Neither site has a stream to point at, so both now raise Error with the message they were meant to carry. The #attr check itself looked for VFN( and VFFSL( but not for VFSL(, which is what the compiler generates when useStackFrames is off. The directive it is supposed to reject went through unnoticed there, which is why the new test only failed without the C version of NameMapper. 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.
Both sites do
raise ParseError(self, ...), butParseError.__init__expects a stream and callsstream.pos()on it.The first happens in
ModuleCompiler.__init__before_setupCompilerState(), so__getattr__recurses on the missing_activeClassesList. Neither site has a stream to point at, so both raiseErrorwith the message they were meant to carry.While testing this: the
#attrcheck looks forVFN(andVFFSL(but notVFSL(, the form generated whenuseStackFramesis off. Without the C version of NameMapper the directive it rejects went through unnoticed, so that check is in this PR too.Two regression tests. Full suite passes on 2.7, 3.6 and 3.12 in both namemapper modes, flake8 clean.