﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
8462	length and length_is filters don't fail silently	magneto	Gary Wilson	"django/template/defaultfilters.py"", line 469, in length

if the input object has no __len__ defined, this throws a nasty exception .. given the very large number of time i imagine this is used

would it be proper to simply 'return 0' for non list like things?

in particular the 'with' command is problematic (if 'my_thing' is unresolved, it blows up)
{{{
{% with my_thing|length as my_length %}

{% endwith %}
}}}

{{{
Index: django/template/defaultfilters.py
===================================================================
--- django/template/defaultfilters.py   (revision 8455)
+++ django/template/defaultfilters.py   (working copy)
@@ -466,7 +466,10 @@
 
 def length(value):
     """"""Returns the length of the value - useful for lists.""""""
-    return len(value)
+    try:
+        return len(value)
+    except:
+        return 0
 length.is_safe = True
 
 def length_is(value, arg):

}}}"		closed	Template system	dev		fixed	length		Ready for checkin	1	0	0	0	0	0
