This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.smith
Recipients abarry, alexomics, eric.smith
Date 2018-05-02.17:06:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1525280793.25.0.682650639539.issue33410@psf.upfronthosting.co.za>
In-reply-to
Content
The problem is that type.__format__ doesn't exist, so object.__format__ is being called, and it throws an error if you provide a format spec. This is done for future expansion: if we do want to add type.__format__ in the future, we don't have to worry about existing cases that are using format specs that might not work with the new type.__format__.

No format spec is the same as calling str() on the argument and returning that, which is what is happening in your working examples.

If you want to apply a str formatting spec, you should covert the argument to a str first, using either !s or str():

>>> print('{a!s: >10}'.format(a=type(a)))
<class 'str'>
>>> print('{a: >10}'.format(a=str(type(a))))
<class 'str'>
History
Date User Action Args
2018-05-02 17:06:33eric.smithsetrecipients: + eric.smith, abarry, alexomics
2018-05-02 17:06:33eric.smithsetmessageid: <1525280793.25.0.682650639539.issue33410@psf.upfronthosting.co.za>
2018-05-02 17:06:33eric.smithlinkissue33410 messages
2018-05-02 17:06:33eric.smithcreate