mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fix #20745: Don't silence TypeError raised inside templates.
Thanks to robin for the report and claudep for the review.
This commit is contained in:
parent
9d11522599
commit
28a571348b
3 changed files with 17 additions and 5 deletions
|
@ -98,6 +98,9 @@ class SomeClass:
|
|||
def method4(self):
|
||||
raise SomeOtherException
|
||||
|
||||
def method5(self):
|
||||
raise TypeError
|
||||
|
||||
def __getitem__(self, key):
|
||||
if key == 'silent_fail_key':
|
||||
raise SomeException
|
||||
|
@ -680,6 +683,9 @@ class TemplateTests(TransRealMixin, TestCase):
|
|||
# Fail silently when accessing a non-simple method
|
||||
'basic-syntax20': ("{{ var.method2 }}", {"var": SomeClass()}, ("","INVALID")),
|
||||
|
||||
# Don't silence a TypeError if it was raised inside a callable
|
||||
'basic-syntax20b': ("{{ var.method5 }}", {"var": SomeClass()}, TypeError),
|
||||
|
||||
# Don't get confused when parsing something that is almost, but not
|
||||
# quite, a template tag.
|
||||
'basic-syntax21': ("a {{ moo %} b", {}, "a {{ moo %} b"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue