]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 70432 via svnmerge from
authorMark Dickinson <dickinsm@gmail.com>
Tue, 17 Mar 2009 18:13:30 +0000 (18:13 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Tue, 17 Mar 2009 18:13:30 +0000 (18:13 +0000)
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.
  ........
................

Lib/decimal.py
Lib/test/test_decimal.py
Misc/NEWS

index 7b1308d1f4008de8a1c70078d0a5012e50d4828a..f879e99fdfcfc43e14f3cfefcbc35be80939c80b 100644 (file)
@@ -5576,9 +5576,9 @@ def _format_align(body, spec_dict):
 
     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 == '^'
index 6b51d13b099fe61ac14282e68d5541077f4c11d9..d60ba73f4728a1f616fe7b9fc9ccfcacf254d1fb 100644 (file)
@@ -694,6 +694,12 @@ class DecimalFormatTest(unittest.TestCase):
             ('.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)
index 96cb91044fb26f08895cc571b1fc15ae969b1730..fd2c3298eb7e983bf6118805af164f53e6a27053 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -24,6 +24,9 @@ Core and Builtins
 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.