mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
* Fix SF #1257731. Make __contains__(), remove(), and discard() only do
a frozenset conversion when the initial search attempt fails with a TypeError and the key is some type of set. Add a testcase. * Eliminate a duplicate if-stmt.
This commit is contained in:
parent
b02c35e208
commit
97979ddc14
1 changed files with 13 additions and 0 deletions
|
@ -213,6 +213,19 @@ class TestJointOps(unittest.TestCase):
|
|||
elem.sub = elem
|
||||
elem.set = set([elem])
|
||||
|
||||
def test_subclass_with_custom_hash(self):
|
||||
# Bug #1257731
|
||||
class H(self.thetype):
|
||||
def __hash__(self):
|
||||
return id(self)
|
||||
s=H()
|
||||
f=set()
|
||||
f.add(s)
|
||||
self.assert_(s in f)
|
||||
f.remove(s)
|
||||
f.add(s)
|
||||
f.discard(s)
|
||||
|
||||
class TestSet(TestJointOps):
|
||||
thetype = set
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue