[prev in list] [next in list] [prev in thread] [next in thread]
List: python-bugs-list
Subject: [Python-bugs-list] [Bug #112558] dictionary lookup does not check exceptions
From: noreply () sourceforge ! net (noreply () sourceforge ! net)
Date: 2000-08-31 19:05:21
Message-ID: 200008311905.MAA13572 () bush ! i ! sourceforge ! net
[Download RAW message or body]
Bug #112558, was updated on 2000-Aug-23 07:24
Here is a current snapshot of the bug.
Project: Python
Category: Core
Status: Closed
Resolution: Fixed
Bug Group: None
Priority: 9
Summary: dictionary lookup does not check exceptions
Details: class BadDictKey:
def __hash__(self):
return hash(self.__class__)
def __cmp__(self, other):
if isinstance(other, self.__class__):
print "raising error"
raise RuntimeError, "gotcha"
return other
The dict lookup code does not check for hash or cmp functions raising an exception. \
This can lead to a variety of bogus behavior; e.g. the uncaught exception is noticed \
and raised for the next line.
> > > d = {}
> > > x1 = BadDictKey()
> > > x2 = BadDictKey()
> > > d[x1] = 1
> > > d[x2] = 2
raising error
> > > print d.keys()
Traceback (most recent call last):
File "/tmp/dicterr.py", line 8, in __cmp__
raise RuntimeError, "gotcha"
RuntimeError: gotcha
Follow-Ups:
Date: 2000-Aug-24 09:56
By: fdrake
Comment:
See patch #101277 for a proposed fix & discussion.
-------------------------------------------------------
Date: 2000-Aug-31 12:05
By: fdrake
Comment:
Fixed by patch #101277, checked in as dictobject.c revision 2.63.
-------------------------------------------------------
For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=112558&group_id=5470
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic