Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 762c1cb

Browse files
committed
Test case to exercise fix for error propogation bug in dictionarys.
1 parent 65faf11 commit 762c1cb

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

Lib/test/output/test_operations

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
test_operations
22
3. Operations
3-
XXX Not yet implemented
3+
XXX Mostly not yet implemented
4+
3.1 Dictionary lookups succeed even if __cmp__() raises an exception
5+
raising error
6+
No exception passed through.

Lib/test/test_operations.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,27 @@
22

33

44
print '3. Operations'
5-
print 'XXX Not yet implemented'
5+
print 'XXX Mostly not yet implemented'
6+
7+
8+
print '3.1 Dictionary lookups succeed even if __cmp__() raises an exception'
9+
10+
# SourceForge bug #112558:
11+
# http://sourceforge.net/bugs/?func=detailbug&bug_id=112558&group_id=5470
12+
13+
class BadDictKey:
14+
def __hash__(self):
15+
return hash(self.__class__)
16+
17+
def __cmp__(self, other):
18+
if isinstance(other, self.__class__):
19+
print "raising error"
20+
raise RuntimeError, "gotcha"
21+
return other
22+
23+
d = {}
24+
x1 = BadDictKey()
25+
x2 = BadDictKey()
26+
d[x1] = 1
27+
d[x2] = 2
28+
print "No exception passed through."

0 commit comments

Comments
 (0)