#27140: TypeError not reported from a template
---------------------------------+--------------------------------------
Reporter: azmeuk | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: 1.10
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by azmeuk):
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Old description:
> If you try to access an object property in a django template, and this
> property raises a TypeError, then nothing will be raised. If it is, let's
> say, a ZeroDivisionError, then the exception is raised.
>
> {{{
> from django.template import Context, Template
> class FooClassTypeError:
> @property
> def fooproperty(self):
> raise TypeError
> return "somevalue"
>
> class FooClass:
> @property
> def fooproperty(self):
> return 1/0
>
> t = Template("{{ obj.fooproperty }}")
>
> # This call does not raise anything
> t.render(Context(dict(obj=FooClassTypeError())))
>
> # This call raises an exception
> t.render(Context(dict(obj=FooClass())))
> }}}
>
> I think the expected behavior is that both exceptions should be raised.
> What do you think?
New description:
If you try to access an object property in a django template, and this
property raises a TypeError, then nothing will be raised. If it raises,
let's say, a ZeroDivisionError, then the exception is raised.
{{{#!python
from django.template import Context, Template
class FooClassTypeError:
@property
def fooproperty(self):
raise TypeError
return "somevalue"
class FooClass:
@property
def fooproperty(self):
return 1/0
t = Template("{{ obj.fooproperty }}")
# This call does not raise anything
t.render(Context(dict(obj=FooClassTypeError())))
# This call raises an exception
t.render(Context(dict(obj=FooClass())))
}}}
I think the expected behavior is that both exceptions should be raised.
What do you think?
--
--
Ticket URL: <https://code.djangoproject.com/ticket/27140#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.7fed0139ef90dbe2d5b0f16d5d58f7cb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.