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 al45tair
Recipients al45tair
Date 2017-09-04.07:01:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1504508470.35.0.035228363229.issue31335@psf.upfronthosting.co.za>
In-reply-to
Content
Currently if you do

  "{:r}".format(None)

you get the error message

  TypeError: non-empty format string passed to object.__format__

or on newer versions

  TypeError: non-empty format string passed to NoneType.__format__

(which is at least *some* improvement).

Similar behaviour occurs for other types that don't implement their own __format__ method.

This seems to me to be an error on two counts:

1. object.__format__ *should* support ":r", and probably ":s" too.

2. It's unclear what the error message actually means (I had to Google it to find out what was going wrong), *especially* in a situation where it isn't obvious that the argument evaluates to None.

Since the error itself would still happen if an unsupported specifier was used, we should improve the message.  A better choice might be

  TypeError: format "{:x}" not supported for type NoneType.
History
Date User Action Args
2017-09-04 07:01:10al45tairsetrecipients: + al45tair
2017-09-04 07:01:10al45tairsetmessageid: <1504508470.35.0.035228363229.issue31335@psf.upfronthosting.co.za>
2017-09-04 07:01:10al45tairlinkissue31335 messages
2017-09-04 07:01:09al45taircreate