[New-bugs-announce] [issue36787] Python3 regresison: String formatting of None object
Gawain Bolton
report at bugs.python.org
Fri May 3 16:30:35 EDT 2019
New submission from Gawain Bolton <gawain.bolton at gmail.com>:
Python 2.7.16 (default, Apr 6 2019, 01:42:57)
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print('{:^10}'.format(None))
None
However this does not work with Python3:
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('{:^10}'.format(None))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported format string passed to NoneType.__format__
Given that the None type is output as a string, it makes sense for string formatting options to be usable with it. It also makes code less fragile and avoids having to write special cases for when values
could be None.
----------
components: Library (Lib)
messages: 341355
nosy: Gawain Bolton
priority: normal
severity: normal
status: open
title: Python3 regresison: String formatting of None object
type: behavior
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36787>
_______________________________________
More information about the New-bugs-announce
mailing list