Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #17496 -- Regression in the floatformat template filter, introd…

…uced by the fix for #15789.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17335 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit e5719b203c5a1ee799cd8cb6100342940e260fd7 1 parent c939334
Aymeric Augustin authored January 03, 2012
2  django/template/defaultfilters.py
@@ -169,7 +169,7 @@ def floatformat(text, arg=-1):
169 169
         # Set the precision high enough to avoid an exception, see #15789.
170 170
         tupl = d.as_tuple()
171 171
         units = len(tupl[1]) - tupl[2]
172  
-        prec = abs(arg) + units + 1
  172
+        prec = abs(p) + units + 1
173 173
 
174 174
         # Avoid conversion to scientific notation by accessing `sign`, `digits`
175 175
         # and `exponent` from `Decimal.as_tuple()` directly.
2  tests/regressiontests/defaultfilters/tests.py
@@ -69,6 +69,8 @@ def __float__(self):
69 69
         try:
70 70
             self.assertEqual(floatformat(1.2345, 2), u'1.23')
71 71
             self.assertEqual(floatformat(15.2042, -3), u'15.204')
  72
+            self.assertEqual(floatformat(1.2345, '2'), u'1.23')
  73
+            self.assertEqual(floatformat(15.2042, '-3'), u'15.204')
72 74
             self.assertEqual(floatformat(decimal.Decimal('1.2345'), 2), u'1.23')
73 75
             self.assertEqual(floatformat(decimal.Decimal('15.2042'), -3), u'15.204')
74 76
         finally:

0 notes on commit e5719b2

Please sign in to comment.
Something went wrong with that request. Please try again.