summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-03-20 07:36:33 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-03-20 07:36:33 +0000
commit516102dc756bdfbb0d71185067d0ec1ab91adef3 (patch)
treef7d24f320fdd6879ca11951f8033807688aa5bb8
parent463a03d7e304a08fbe9af85de241746d5f242391 (diff)
FIxed #6513 -- Handle overflows better in the floatformat filter. It's not
possible to test this automatically everywhere due to differing representations on different platforms. Manual testing confirms it works, though. Thanks, Karen Tracey. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7336 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/template/defaultfilters.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index 8e5bcf5bd8..cef314387a 100644
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -124,7 +124,10 @@ def floatformat(text, arg=-1):
d = int(arg)
except ValueError:
return force_unicode(f)
- m = f - int(f)
+ try:
+ m = f - int(f)
+ except OverflowError:
+ return force_unicode(f)
if not m and d < 0:
return mark_safe(u'%d' % int(f))
else: