[Python-checkins] r70430 - in python/trunk: Lib/decimal.py Lib/test/test_decimal.py Misc/NEWS
mark.dickinson
python-checkins at python.org
Tue Mar 17 19:01:03 CET 2009
Author: mark.dickinson
Date: Tue Mar 17 19:01:03 2009
New Revision: 70430
Log:
Fix bug in Decimal __format__ method that swapped left and right
alignment.
Modified:
python/trunk/Lib/decimal.py
python/trunk/Lib/test/test_decimal.py
python/trunk/Misc/NEWS
Modified: python/trunk/Lib/decimal.py
==============================================================================
--- python/trunk/Lib/decimal.py (original)
+++ python/trunk/Lib/decimal.py Tue Mar 17 19:01:03 2009
@@ -5551,9 +5551,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/trunk/Lib/test/test_decimal.py
==============================================================================
--- python/trunk/Lib/test/test_decimal.py (original)
+++ python/trunk/Lib/test/test_decimal.py Tue Mar 17 19:01:03 2009
@@ -704,6 +704,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/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Tue Mar 17 19:01:03 2009
@@ -174,6 +174,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