]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 74706 via svnmerge from
authorMark Dickinson <dickinsm@gmail.com>
Mon, 7 Sep 2009 16:23:26 +0000 (16:23 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Mon, 7 Sep 2009 16:23:26 +0000 (16:23 +0000)
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://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.
  ........
................

Lib/decimal.py
Lib/test/test_decimal.py
Misc/NEWS

index 8d82cb9f578b5e32fd74fefd20b8b33ccaed5007..e3af3f0812befa06302d693fd32c8a995adcdc36 100644 (file)
@@ -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
index 927fd1a3d48ec3872c3a924edbf931233369d054..f0c44315bdb731a206c1c383248dcc2d1a8434dd 100644 (file)
@@ -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)
index 80ebfa1a8c4f3ef575bd77e7e26d5c2a9c246f2b..3a9b0b9c14e4705d070306e1b80e289e7ce6da86 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -52,6 +52,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