Issue2691
Created on 2018-06-12.11:17:48 by _peter_holloway, last changed 2018-08-10.21:10:44 by jeff.allen.
msg12008 (view) |
Author: Peter Holloway (_peter_holloway) |
Date: 2018-06-12.11:17:48 |
|
In cPython 2.7.12, '{}'.format(True) results in the string 'True'.
In Jython 2.7.1, the same line results in '1'.
|
msg12078 (view) |
Author: Jeff Allen (jeff.allen) |
Date: 2018-08-10.21:10:43 |
|
This isn't as obviously wrong as it looks at first.
I would say we have followed the convention that no type means "d":
>>> True.__format__("10")
' 1'
>>> True.__format__("<")
'1'
>>> True.__format__("d")
'1'
But we missed the convention that an empty format string ("") produces the same result as if you had called str() on the value.
>>> True.__format__("")
'True'
See: https://docs.python.org/2/library/string.html#format-specification-mini-language
I'm surprised that nothing in the regression tests has caught this, but there just isn't one in the Python suite. So a solution should start with a failing test in (I think) test_format_jy checking this for True and False, and maybe a few where it is 1, 0 for good measure.
|
|
Date |
User |
Action |
Args |
2018-08-10 21:10:44 | jeff.allen | set | keywords:
+ easy priority: normal resolution: accepted messages:
+ msg12078 nosy:
+ jeff.allen |
2018-06-12 11:17:48 | _peter_holloway | create | |
|