Skip to content

Unknown expression type raises bare LookupError instead of ExpressionError #458

Closed

Description

@rahul05ranjan

Summary

An unknown or misspelled TALES expression type raises a bare LookupError with no source location, instead of one of the documented TemplateError subclasses:

>>> from chameleon.zpt.template import PageTemplate
>>> PageTemplate('<div tal:content="nocall: some_var">t</div>')
Traceback (most recent call last):
  ...
LookupError: Unknown expression type: 'nocall'.

chameleon/tales.py, ExpressionParser.__call__ (line 539). The same happens for any typo like strng:, pathh: etc. — this is the class of "badly handled template errors" from #298/#291: the user gets an internal-looking exception with no expression or position information, while e.g. a syntax error inside a python: expression properly raises ExpressionError with the source location.

nocall: itself is not a supported expression type in Chameleon (it's standard TALES, but not registered in the default engine), so this input is currently invalid — but it should fail as a language error, not as an internal LookupError.

Expected

Raise chameleon.exc.ExpressionError with the offending source so the error renders with the expression and location, the same way other expression syntax errors do.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions