mirror of
https://github.com/python/cpython.git
synced 2025-09-19 15:10:58 +00:00
Test case to exercise fix for error propogation bug in dictionarys.
This commit is contained in:
parent
65faf118b6
commit
762c1cb3e3
2 changed files with 28 additions and 2 deletions
|
@ -1,3 +1,6 @@
|
||||||
test_operations
|
test_operations
|
||||||
3. Operations
|
3. Operations
|
||||||
XXX Not yet implemented
|
XXX Mostly not yet implemented
|
||||||
|
3.1 Dictionary lookups succeed even if __cmp__() raises an exception
|
||||||
|
raising error
|
||||||
|
No exception passed through.
|
||||||
|
|
|
@ -2,4 +2,27 @@
|
||||||
|
|
||||||
|
|
||||||
print '3. Operations'
|
print '3. Operations'
|
||||||
print 'XXX Not yet implemented'
|
print 'XXX Mostly not yet implemented'
|
||||||
|
|
||||||
|
|
||||||
|
print '3.1 Dictionary lookups succeed even if __cmp__() raises an exception'
|
||||||
|
|
||||||
|
# SourceForge bug #112558:
|
||||||
|
# http://sourceforge.net/bugs/?func=detailbug&bug_id=112558&group_id=5470
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
d = {}
|
||||||
|
x1 = BadDictKey()
|
||||||
|
x2 = BadDictKey()
|
||||||
|
d[x1] = 1
|
||||||
|
d[x2] = 2
|
||||||
|
print "No exception passed through."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue