Fixed #6030 -- More robust error handling for the "float" filter. Thanks,
SmileyChris. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6752 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
caa0523cb8
commit
5d1d054e15
|
@ -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)
|
||||||
|
|
|
@ -37,6 +37,8 @@ u''
|
||||||
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\\\''
|
||||||
|
|
Loading…
Reference in New Issue