[ python-Bugs-1249837 ] container methods raise KeyError not IndexError

SourceForge.net noreply at sourceforge.net
Mon Aug 1 22:47:44 CEST 2005


Bugs item #1249837, was opened at 2005-08-01 13:47
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=1249837&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: Documentation
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Wilfredo Sanchez (wsanchez)
Assigned to: Nobody/Anonymous (nobody)
Summary: container methods raise KeyError not IndexError

Initial Comment:
See: http://www.python.org/doc/2.3.5/ref/sequence-types.html, which 
says, for example, that __getitem__(self, key) should raise an 
IndexError if key is not in the container.

However, built-in dicts raise KeyError instead, and http://
www.python.org/doc/2.3.5/lib/module-exceptions.html#l2h-289 
implies that this is the correct behavior.

This appears to be incorrect in the current documentation as well as 
in the 2.3.5 docs.

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

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


More information about the Python-bugs-list mailing list