summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-09-07 16:19:35 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2009-09-07 16:19:35 (GMT)
commitc3c112da6bf2e9bbf78a9fa382deb5a5441f1a6e (patch)
tree8181a2e90b4a8edbd884f203ef61282bbb5dc301
parent02a9ce3edb32938b52dce6374341d03ef258bdf7 (diff)
downloadcpython-c3c112da6bf2e9bbf78a9fa382deb5a5441f1a6e.zip
cpython-c3c112da6bf2e9bbf78a9fa382deb5a5441f1a6e.tar.gz
cpython-c3c112da6bf2e9bbf78a9fa382deb5a5441f1a6e.tar.bz2
Merged revisions 74704 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r74704 | mark.dickinson | 2009-09-07 17:17:41 +0100 (Mon, 07 Sep 2009) | 3 lines Issue #6850: Fix bug in Decimal._parse_format_specifier for formats with no type specifier. ........
-rw-r--r--Lib/decimal.py2
-rw-r--r--Lib/test/test_decimal.py3
-rw-r--r--Misc/NEWS3
3 files changed, 7 insertions, 1 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py
index 7c90f0a..4108fb8 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -5447,7 +5447,7 @@ def _parse_format_specifier(format_spec):
# if format type is 'g' or 'G' then a precision of 0 makes little
# sense; convert it to 1. Same if format type is unspecified.
if format_dict['precision'] == 0:
- if format_dict['type'] in 'gG' or format_dict['type'] is None:
+ if format_dict['type'] is None or format_dict['type'] in 'gG':
format_dict['precision'] = 1
# record whether return type should be str or unicode
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index e82a9b9..79b6a85 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -716,6 +716,9 @@ class DecimalFormatTest(unittest.TestCase):
('>6', '123', ' 123'),
('^6', '123', ' 123 '),
('=+6', '123', '+ 123'),
+
+ # issue 6850
+ ('a=-7.0', '0.12345', 'aaaa0.1'),
]
for fmt, d, result in test_values:
self.assertEqual(format(Decimal(d), fmt), result)
diff --git a/Misc/NEWS b/Misc/NEWS
index 3522fc8..3162b5a 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -74,6 +74,9 @@ Core and Builtins
Library
-------
+- Issue #6850: Fix bug in Decimal._parse_format_specifier for formats
+ with no type specifier.
+
- Issue #4937: plat-mac/bundlebuilder revers to non-existing version.plist
- Issue #6838: Use a list to accumulate the value instead of