[Python-bugs-list] [Bug #125598] Confusing KeyError-Message when key is tuple of size 1

noreply@sourceforge.net noreply@sourceforge.net
Wed, 13 Dec 2000 02:38:04 -0800


Bug #125598, was updated on 2000-Dec-13 02:38
Here is a current snapshot of the bug.

Project: Python
Category: None
Status: Open
Resolution: None
Bug Group: Feature Request
Priority: 5
Submitted by: murple
Assigned to : nobody
Summary: Confusing KeyError-Message when key is tuple of size 1 

Details: Following caused some confusion for me:

>>> dic = {1:1,2:"bla"}
>>> dic[1]
1
>>> b = (1,)
#1000 lines of code
>>> dic[b]
Traceback (innermost last):
  File "<stdin>", line 1, in ?
KeyError: 1
# This should be KeyError: (1,) 
# because 1 is a valid key for dic 
>>> dic[(1,2)]
Traceback (innermost last):
  File "<stdin>", line 1, in ?
KeyError: (1, 2)
>>> 


For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=125598&group_id=5470