[Python-checkins] r70433 - in python/branches/release30-maint: Lib/decimal.py Lib/test/test_decimal.py Misc/NEWS

mark.dickinson python-checkins at python.org
Tue Mar 17 19:13:31 CET 2009


Author: mark.dickinson
Date: Tue Mar 17 19:13:30 2009
New Revision: 70433

Log:
Merged revisions 70432 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r70432 | mark.dickinson | 2009-03-17 18:10:15 +0000 (Tue, 17 Mar 2009) | 10 lines
  
  Merged revisions 70430 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r70430 | mark.dickinson | 2009-03-17 18:01:03 +0000 (Tue, 17 Mar 2009) | 3 lines
    
    Fix bug in Decimal __format__ method that swapped left and right
    alignment.
  ........
................


Modified:
   python/branches/release30-maint/   (props changed)
   python/branches/release30-maint/Lib/decimal.py
   python/branches/release30-maint/Lib/test/test_decimal.py
   python/branches/release30-maint/Misc/NEWS

Modified: python/branches/release30-maint/Lib/decimal.py
==============================================================================
--- python/branches/release30-maint/Lib/decimal.py	(original)
+++ python/branches/release30-maint/Lib/decimal.py	Tue Mar 17 19:13:30 2009
@@ -5576,9 +5576,9 @@
 
     align = spec_dict['align']
     if align == '<':
-        result = padding + sign + body
-    elif align == '>':
         result = sign + body + padding
+    elif align == '>':
+        result = padding + sign + body
     elif align == '=':
         result = sign + padding + body
     else: #align == '^'

Modified: python/branches/release30-maint/Lib/test/test_decimal.py
==============================================================================
--- python/branches/release30-maint/Lib/test/test_decimal.py	(original)
+++ python/branches/release30-maint/Lib/test/test_decimal.py	Tue Mar 17 19:13:30 2009
@@ -694,6 +694,12 @@
             ('.0g', '-sNaN', '-sNaN'),
 
             ('', '1.00', '1.00'),
+
+            # check alignment
+            ('<6', '123', '123   '),
+            ('>6', '123', '   123'),
+            ('^6', '123', ' 123  '),
+            ('=+6', '123', '+  123'),
             ]
         for fmt, d, result in test_values:
             self.assertEqual(format(Decimal(d), fmt), result)

Modified: python/branches/release30-maint/Misc/NEWS
==============================================================================
--- python/branches/release30-maint/Misc/NEWS	(original)
+++ python/branches/release30-maint/Misc/NEWS	Tue Mar 17 19:13:30 2009
@@ -24,6 +24,9 @@
 Library
 -------
 
+- Fix Decimal.__format__ bug that swapped the meanings of the '<' and
+  '>' alignment characters.
+
 - Issue #1222: locale.format() bug when the thousands separator is a space
   character.
 


More information about the Python-checkins mailing list