On Fri, 2009-02-20 at 11:38 -0800, Ben Gerdemann wrote:
> I just spent a good part of my afternoon tracking down a bug in my
> code, that eventually turned out to be a Unicode encoding problem. The
> reason it took me so long to track down the problem is this code here
> in 'template/__init__.py':
> 
> 794   class VariableNode(Node):
> ...
> 801       def render(self, context):
> 802           try:
> 803               output = force_unicode(self.filter_expression.resolve
> (context))
> 804           except UnicodeDecodeError:
> 805               # Unicode conversion can fail sometimes for reasons
> out of our
> 806               # control (e.g. exception rendering). In that case,
> we fail quietly.
> 807               return ''
> 
> Is there a good reason that the widget rendering is silently capturing
> all Unicode errors?

Yes. Non-developer-controlled content (which is usually what's being
converted by filters) should not be allowed to crash template rendering.
The data coming into the template variables could be from a lot of
location and, as a final fallback, if it gets that far without being
caught, I decided not to let it blow up the rendering process.

Similarly, inserting an error string isn't the right thing to do by
default, as it's more or less entirely unhelpful to the user.

All that being said, if you want to come up with a patch to introduce
something similar to TEMPLATE_STRING_IF_INVALID that is inserted in
cases like that (including something like the "%s" support for that
setting) when developers are debugging, that would probably be a good
idea. 

End of the day, though, the current (default) behaviour is not to be
distracting to the end reader of the site. You're right that it
inadvertently impacts development, so let's fix that problem as well.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to