Repository navigation
fix: raise ExpressionError for an unknown expression type - #460
Merged
malthe merged 2 commits intoNov 13, 2026
Merged
Conversation
An unknown or misspelled expression type (e.g. nocall: or strng:) raised a bare LookupError with no source location. Raise the documented ExpressionError so the error is reported with the template source instead. Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
Contributor
Author
|
Thank you for the merge! 🎉 |
Coverage Report for CI Build 43378129287Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage increased (+0.05%) to 92.859%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
This comment was marked as off-topic.
This comment was marked as off-topic.
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.
Fixes #458.
Problem
ExpressionParser.__call__raised a bareLookupError("Unknown expression type: 'nocall'.")for any unknown or misspelled expression type, with no source location — an internal-looking exception for what is a template language error.Fix
Raise the documented
chameleon.exc.ExpressionErrorinstead, passing the full expression source so the error renders with the expression and its location like other expression errors:The message text is unchanged.
Verification
New regression test
test_unknown_expression_type_raises_expression_errorfails on un-fixed HEAD (a7d8f8f) withLookupErrorand passes with this patch:on CPython 3.13 (system Python, Raspberry Pi OS): 234 passed, 5 failed — the 5 failures are the pre-existing loader/egg/wheel packaging tests that also fail on un-fixed HEAD with byte-identical output (they need wheel/egg installation machinery this host doesn't have).
Co-authored-by: rahul05ranjan 11793455+rahul05ranjan@users.noreply.github.com