Skip to content
Myr

Better error messages for some undefines. This fixes #575

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent a4dde4b · Browse files · 2 files+14 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+14 added−2 removed

  • other:+14 added−2 removed

2 files+14 added−2 removed

modified:jinja2/environment.py+12 added-2 removed
86 unmodified lines
87 result[extension.identifier] = extension(environment)88 return result899091def fail_for_missing_callable(string, name):92 msg = string % name93 if isinstance(name, Undefined):94 try:95 name._fail_with_undefined_error()96 except Exception as e:97 msg = '%s (%s; did you forget to quote the callable name?)' % (msg, e)98 raise TemplateRuntimeError(msg)99100101def _environment_sanity_check(environment):102 """Perform a sanity check on the environment."""103 assert issubclass(environment.undefined, Undefined), 'undefined must ' \104 'be a subclass of undefined because filters depend on it.'
343 unmodified lines
448 .. versionadded:: 2.7449 """450 func = self.filters.get(name)451 if func is None:442 raise TemplateRuntimeError('no filter named %r' % name)452 fail_for_missing_callable('no filter named %r', name)453 args = [value] + list(args or ())454 if getattr(func, 'contextfilter', False):455 if context is None:456 raise TemplateRuntimeError('Attempted to invoke context '
16 unmodified lines
473 .. versionadded:: 2.7474 """475 func = self.tests.get(name)476 if func is None:467 raise TemplateRuntimeError('no test named %r' % name)477 fail_for_missing_callable('no test named %r', name)478 return func(value, *(args or ()), **(kwargs or {}))479480 @internalcode481 def parse(self, source, name=None, filename=None):
797 unmodified lines
modified:CHANGES+2 added
16 unmodified lines
17- Support toplevel set statements in extend situations.18- Restored behavior of Cycler for Python 3 users.19- Subtraction now follows the same behavior as other operators on undefined20 values.21- `map` and friends will now give better error messages if you forgot to22 quote the parameter.2324Version 2.8.225-------------26
381 unmodified lines