[issue36787] Python3 regresison: String formatting of None object

Zachary Ware report at bugs.python.org
Fri May 3 16:50:24 EDT 2019


Zachary Ware <zachary.ware at gmail.com> added the comment:

You can use `!s` to be sure that the object is a string:

>>> '{!s:^10}'.format(None)
'   None   '

I think it's unlikely the behavior of NoneType.__format__ will be changed, but I'm adding Eric Smith to make that determination as the maintainer of str.format.

See issue7994 for the background on the change that produced this behavior.

----------
nosy: +eric.smith, zach.ware
versions: +Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36787>
_______________________________________


More information about the Python-bugs-list mailing list