Browse files

Fixed #6030 -- More robust error handling for the "float" filter. Tha…

…nks,

SmileyChris.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6752 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent caa0523 commit 5d1d054e150bace05b8826d990d71c46834eef87 @malcolmt malcolmt committed Nov 29, 2007
Showing with 3 additions and 1 deletion.
  1. +1 −1 django/template/defaultfilters.py
  2. +2 −0 tests/regressiontests/defaultfilters/tests.py
View
2 django/template/defaultfilters.py
@@ -91,7 +91,7 @@ def floatformat(text, arg=-1):
"""
try:
f = float(text)
- except ValueError:
+ except (ValueError, TypeError):
return u''
try:
d = int(arg)
View
2 tests/regressiontests/defaultfilters/tests.py
@@ -37,6 +37,8 @@
u'13.1031'
>>> floatformat(u'foo', u'bar')
u''
+>>> floatformat(None)
+u''
>>> addslashes(u'"double quotes" and \'single quotes\'')
u'\\"double quotes\\" and \\\'single quotes\\\''

0 comments on commit 5d1d054

Please sign in to comment.