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: The KeyError message doesn't use repr on the key value repor
Type: Stage:
Components: Interpreter Core Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, r.david.murray
Priority: normal Keywords:

Created on 2002-08-21 20:22 by r.david.murray, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (3)
msg12093 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2002-08-21 20:22
>>> {}[1]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
KeyError: 1
>>> {}['']
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
KeyError

Note that the second message is very confusing if you don't
know that it means the KeyError is on a blank key.  In any
case I think KeyError should use repr on the key value in
order to make it clear what is being used as the key.  According
to zigg, that should also fix the fact that the : goes missing
in the second case.
msg12094 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-09-03 19:34
Logged In: YES 
user_id=6380

This could be considered a feature -- it was done this way
on purpose. But it's a very annoying feature, and I think we
may want to change this. I'll see if I can get some feedback
from python-dev. Since it's a feature change, I can only
change this in 2.3, not in 2.2.2.
msg12095 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-09-03 20:25
Logged In: YES 
user_id=6380

Fixed in CVS head.
History
Date User Action Args
2022-04-10 16:05:36adminsetgithub: 37070
2002-08-21 20:22:56rdmurraycreate