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.

classification
Title: Misleading error message for str.format()
Type: behavior Stage:
Components: Interpreter Core Versions: Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: In str.format an incorrect error message for list, tuple, dict, set
View: 13790
Assigned To: Nosy List: eric.smith, theisenm
Priority: normal Keywords:

Created on 2012-05-04 18:21 by theisenm, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg159955 - (view) Author: Mark Theisen (theisenm) Date: 2012-05-04 18:21
When I run this code: '{0:i}'.format(None)

I get this error:
ValueError: Unknown format code 'i' for object of type 'str'

This seems misleading because None is of Type 'NoneType'. I was expecting the error to say something to the effect of:
Unknown format code 'i' for object of type 'NoneType'
msg159957 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2012-05-04 18:25
This is a duplicate of issue 13790. See the comments there for why it works this way.
History
Date User Action Args
2022-04-11 14:57:29adminsetgithub: 58928
2012-05-04 18:25:14eric.smithsetstatus: open -> closed

nosy: + eric.smith
messages: + msg159957

superseder: In str.format an incorrect error message for list, tuple, dict, set
resolution: duplicate
2012-05-04 18:21:12theisenmcreate