[ python-Bugs-1576657 ] dict keyerror formatting and tuples
SourceForge.net
noreply at sourceforge.net
Fri Oct 13 18:00:54 CEST 2006
Bugs item #1576657, was opened at 2006-10-13 18:00
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1576657&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: M.-A. Lemburg (lemburg)
Assigned to: Nobody/Anonymous (nobody)
Summary: dict keyerror formatting and tuples
Initial Comment:
Probably just a minor glitch, but one which caused me
half an hour to track down:
>>> d = {1:'x'}
>>> v = (1,)
>>> d[v]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 1
Note the formatting of the error message. It reads '1',
not '(1,)' as you would expect.
The example is constructed. In the code I was
debugging, I didn't know that v was a tuple and thought
it was the integer 1 - so the KeyError itself was
somewhat puzzling.
Only after printing the key I found that the lookup
failed due to a type error.
This happens in Python 2.4 and 2.5.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1576657&group_id=5470
More information about the Python-bugs-list
mailing list