diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2009-03-17 18:01:03 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2009-03-17 18:01:03 (GMT) |
commit | b065e52bc284c2c28a967c4e82aa7ece6d09c562 (patch) | |
tree | 446dec7a95dafe2d40c85f89ae0fb1aa9fc076a3 | |
parent | 8cbe9556cf4ad10c0ee2636f43f4f3675a8c6203 (diff) | |
download | cpython-b065e52bc284c2c28a967c4e82aa7ece6d09c562.zip cpython-b065e52bc284c2c28a967c4e82aa7ece6d09c562.tar.gz cpython-b065e52bc284c2c28a967c4e82aa7ece6d09c562.tar.bz2 |
Fix bug in Decimal __format__ method that swapped left and right
alignment.
-rw-r--r-- | Lib/decimal.py | 4 | ||||
-rw-r--r-- | Lib/test/test_decimal.py | 6 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
3 files changed, 11 insertions, 2 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py index 1d12e87..2b16e6a 100644 --- a/Lib/decimal.py +++ b/Lib/decimal.py @@ -5551,9 +5551,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 == '^' diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index 65aa033..eed1eed 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -704,6 +704,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) @@ -174,6 +174,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. |