Bugs item #1614429, was opened at 2006-12-13 02:48 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=1614429&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: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: toidinamai (toidinamai) Assigned to: Nobody/Anonymous (nobody) Summary: dict throwing inaccurate KeyError on small tuple keys Initial Comment: When using tuples of length one as keys for the builtin dictionary the Python runtime raises an inaccurate KeyError exception that makes some errors hard to find: Python 2.5 (r25:51908, Dec 12 2006, 18:39:30) [GCC 4.1.1 (Gentoo 4.1.1-r1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> {"foo":"bar"}[("foo",)] Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError: 'foo' Also the error messages for the empty tuple and None are indistinguishable: Python 2.5 (r25:51908, Dec 12 2006, 18:39:30) [GCC 4.1.1 (Gentoo 4.1.1-r1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> {None:"bar"}[()] Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError >>> {():"bar"}[None] Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError This also seems to be the case for earlier versions of Python. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1614429&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com