[issue36787] Python3 regresison: String formatting of None object
Eric V. Smith
report at bugs.python.org
Fri May 3 18:00:15 EDT 2019
Eric V. Smith <eric at trueblade.com> added the comment:
This behavior isn't going to change. As Zach says, if you want to convert any value to a string, use !s. We want to fail as soon as possible: if a class (such as NoneType) doesn't implement __format__, then trying to format an instance with a format spec that doesn't apply to it should be an error. If you want to support strings or None, then it's your job to ensure the conversion.
As issue7994 says, one of the big drivers of this change (I'll argue it's really a bugfix) was that you could never add __format__ to class if it didn't previously have one. Or if you did, it would have to support at least the string format spec, since there might be code that formatted it with "^10", for example.
As things currently stand, we could add __format__ to NoneType and have "T/F" mean convert to "True" or "False". If NoneTypes were already format-able with "^10", this change wouldn't be possible.
----------
assignee: -> eric.smith
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36787>
_______________________________________
More information about the Python-bugs-list
mailing list