Skip to content

Report two compiler errors instead of crashing - #82

Open
hilman2 wants to merge 1 commit into
CheetahTemplate3:masterfrom
hilman2:fix-error-paths
Open

Report two compiler errors instead of crashing#82
hilman2 wants to merge 1 commit into
CheetahTemplate3:masterfrom
hilman2:fix-error-paths

Conversation

@hilman2

@hilman2 hilman2 commented Aug 26, 2026

Copy link
Copy Markdown

Both sites do raise ParseError(self, ...), but ParseError.__init__ expects a stream and calls stream.pos() on it.

#unicode utf-8            RecursionError: maximum recursion depth exceeded
#encoding utf-8

#attr $test = $foo        AttributeError: pos

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 raise Error with the message they were meant to carry.

While testing this: the #attr check looks for VFN( and VFFSL( but not VFSL(, the form generated when useStackFrames is 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.

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

2 participants