mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
Fix SF bug #1546288, crash in dict_equal.
This commit is contained in:
parent
c4a70fbb78
commit
a22975fb35
3 changed files with 15 additions and 2 deletions
|
@ -91,12 +91,17 @@ class Horrid:
|
|||
self.hashcode = random.randrange(1000000000)
|
||||
|
||||
def __hash__(self):
|
||||
return 42
|
||||
return self.hashcode
|
||||
|
||||
def __cmp__(self, other):
|
||||
maybe_mutate() # The point of the test.
|
||||
return cmp(self.i, other.i)
|
||||
|
||||
def __eq__(self, other):
|
||||
maybe_mutate() # The point of the test.
|
||||
return self.i == other.i
|
||||
|
||||
def __repr__(self):
|
||||
return "Horrid(%d)" % self.i
|
||||
|
||||
|
@ -132,7 +137,10 @@ def test_one(n):
|
|||
while dict1 and len(dict1) == len(dict2):
|
||||
if verbose:
|
||||
print ".",
|
||||
c = cmp(dict1, dict2)
|
||||
if random.random() < 0.5:
|
||||
c = cmp(dict1, dict2)
|
||||
else:
|
||||
c = dict1 == dict2
|
||||
if verbose:
|
||||
print
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue