mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #5920: Changed format.__float__ and complex.__float__ to use a precision of 12 when using the empty presentation type. This more closely matches str()'s behavior and reduces surprises when adding alignment flags to an empty format string. Patch by Mark Dickinson.
This commit is contained in:
parent
86a05ecdb5
commit
63376228a3
9 changed files with 68 additions and 51 deletions
|
@ -284,6 +284,13 @@ class FormatTestCase(unittest.TestCase):
|
|||
self.assertEqual(format(0.01, ''), '0.01')
|
||||
self.assertEqual(format(0.01, 'g'), '0.01')
|
||||
|
||||
# empty presentation type should format in the same way as str
|
||||
# (issue 5920)
|
||||
x = 100/7.
|
||||
self.assertEqual(format(x, ''), str(x))
|
||||
self.assertEqual(format(x, '-'), str(x))
|
||||
self.assertEqual(format(x, '>'), str(x))
|
||||
self.assertEqual(format(x, '2'), str(x))
|
||||
|
||||
self.assertEqual(format(1.0, 'f'), '1.000000')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue