diff options
-rw-r--r-- | Lib/decimal.py | 2 | ||||
-rw-r--r-- | Lib/test/test_decimal.py | 3 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
3 files changed, 7 insertions, 1 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py index 8d82cb9..e3af3f0 100644 --- a/Lib/decimal.py +++ b/Lib/decimal.py @@ -5592,7 +5592,7 @@ def _parse_format_specifier(format_spec, _localeconv=None): # 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 # determine thousands separator, grouping, and decimal separator, and diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index 927fd1a..f0c4431 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -749,6 +749,9 @@ class DecimalFormatTest(unittest.TestCase): (',%', '123.456789', '12,345.6789%'), (',e', '123456', '1.23456e+5'), (',E', '123456', '1.23456E+5'), + + # issue 6850 + ('a=-7.0', '0.12345', 'aaaa0.1'), ] for fmt, d, result in test_values: self.assertEqual(format(Decimal(d), fmt), result) @@ -70,6 +70,9 @@ C-API Library ------- +- Issue #6850: Fix bug in Decimal._parse_format_specifier for formats + with no type specifier. + - Issue #6239: ctypes.c_char_p return value must return bytes. - Issue #6838: Use a list to accumulate the value instead of |