Skip to content

Commit

Permalink
Fixed #6030 -- More robust error handling for the "float" filter. Tha…
Browse files Browse the repository at this point in the history
…nks,

SmileyChris.


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

0 comments on commit 5d1d054

Please sign in to comment.