Skip to content
Myr

Setting __sub__ equal to _fail_with_undefined_error so subtractions with

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

undefined variables will fail properly like other arithemtic operations.

authored by Nick Garcia · committed by Nick Garcia · parent 5b49845 · Browse files · 2 files+3 added−1 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+3 added−1 removed

  • tests:+2 added−0 removed
  • other:+1 added−1 removed

2 files+3 added−1 removed

modified:jinja2/runtime.py+1 added-1 removed
496 unmodified lines
497 __add__ = __radd__ = __mul__ = __rmul__ = __div__ = __rdiv__ = \498 __truediv__ = __rtruediv__ = __floordiv__ = __rfloordiv__ = \499 __mod__ = __rmod__ = __pos__ = __neg__ = __call__ = \500 __getitem__ = __lt__ = __le__ = __gt__ = __ge__ = __int__ = \501 __float__ = __complex__ = __pow__ = __rpow__ = \501 __float__ = __complex__ = __pow__ = __rpow__ = __sub__ = \502 _fail_with_undefined_error503504 def __eq__(self, other):505 return type(self) is type(other)
162 unmodified lines
modified:tests/test_api.py+2 added
242 unmodified lines
243 assert env.from_string('{{ missing is not defined }}').render() \244 == 'True'245 assert env.from_string('{{ foo.missing }}').render(foo=42) == ''246 assert env.from_string('{{ not missing }}').render() == 'True'247 pytest.raises(UndefinedError,248 env.from_string('{{ missing - 1}}').render)249250 def test_debug_undefined(self):251 env = Environment(undefined=DebugUndefined)252 assert env.from_string('{{ missing }}').render() == '{{ missing }}'
77 unmodified lines