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

noreply@sourceforge.net noreply@sourceforge.net
Tue, 03 Sep 2002 13:25:08 -0700


Bugs item #598451, was opened at 2002-08-21 16: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.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: R. David Murray (rdmurray)
Assigned to: Guido van Rossum (gvanrossum)
Summary: The KeyError message doesn't use repr on the key value repor

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.


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

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-09-03 16:25

Message:
Logged In: YES 
user_id=6380

Fixed in CVS head.

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-09-03 15:34

Message:
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.

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

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