]> granicus.if.org Git - python/commitdiff
Merged revisions 74704 via svnmerge from
authorMark Dickinson <dickinsm@gmail.com>
Mon, 7 Sep 2009 16:19:35 +0000 (16:19 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Mon, 7 Sep 2009 16:19:35 +0000 (16:19 +0000)
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 7c90f0a8910bb59fc34e95e15c888b3270d077d8..4108fb8901e2cab8c2684cff4946865155505489 100644 (file)
@@ -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
index e82a9b9023677deb05367e8e3a939dd8857b3f48..79b6a8563d996c0340d47f6a46adb7557fd54274 100644 (file)
@@ -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)
index 3522fc86ca99bc7d87bf4364bdb1f491a9a35829..3162b5a903055d3fe726f41f0b0734cbee5006de 100644 (file)
--- 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