Skip to content

Commit 781468d

Browse files
author
mark.dickinson
committed
Merged revisions 74706 via svnmerge from
svn+ssh://pythondev@www.python.org/python/branches/py3k ................ r74706 | mark.dickinson | 2009-09-07 17:21:56 +0100 (Mon, 07 Sep 2009) | 10 lines Merged revisions 74704 via svnmerge from svn+ssh://[email protected]/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. ........ ................ git-svn-id: http://svn.python.org/projects/python/branches/release31-maint@74707 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 717d0c5 commit 781468d

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

Lib/decimal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5592,7 +5592,7 @@ def _parse_format_specifier(format_spec, _localeconv=None):
55925592
# if format type is 'g' or 'G' then a precision of 0 makes little
55935593
# sense; convert it to 1. Same if format type is unspecified.
55945594
if format_dict['precision'] == 0:
5595-
if format_dict['type'] in 'gG' or format_dict['type'] is None:
5595+
if format_dict['type'] is None or format_dict['type'] in 'gG':
55965596
format_dict['precision'] = 1
55975597

55985598
# determine thousands separator, grouping, and decimal separator, and

Lib/test/test_decimal.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,9 @@ def test_formatting(self):
749749
(',%', '123.456789', '12,345.6789%'),
750750
(',e', '123456', '1.23456e+5'),
751751
(',E', '123456', '1.23456E+5'),
752+
753+
# issue 6850
754+
('a=-7.0', '0.12345', 'aaaa0.1'),
752755
]
753756
for fmt, d, result in test_values:
754757
self.assertEqual(format(Decimal(d), fmt), result)

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ C-API
5252
Library
5353
-------
5454

55+
- Issue #6850: Fix bug in Decimal._parse_format_specifier for formats
56+
with no type specifier.
57+
5558
- Issue #6239: ctypes.c_char_p return value must return bytes.
5659

5760
- Issue #6838: Use a list to accumulate the value instead of

0 commit comments

Comments
 (0)