[Python-bugs-list] [ python-Bugs-598451 ] The KeyError message doesn't use repr on the key value reported

noreply@sourceforge.net noreply@sourceforge.net
Wed, 21 Aug 2002 13:22:56 -0700


Bugs item #598451, was opened at 2002-08-21 12:22
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=598451&group_id=5470

Category: Python Interpreter Core
Group: Python 2.2.1
Status: Open
Resolution: None
Priority: 5
Submitted By: R. David Murray (rdmurray)
Assigned to: Nobody/Anonymous (nobody)
Summary: The KeyError message doesn't use repr on the key value reported

Initial Comment:
>>> {}[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.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=598451&group_id=5470