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

Skip to content

Commit 97979dd

Browse files
committed
* 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.
1 parent b02c35e commit 97979dd

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

Lib/test/test_set.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,19 @@ class A:
213213
elem.sub = elem
214214
elem.set = set([elem])
215215

216+
def test_subclass_with_custom_hash(self):
217+
# Bug #1257731
218+
class H(self.thetype):
219+
def __hash__(self):
220+
return id(self)
221+
s=H()
222+
f=set()
223+
f.add(s)
224+
self.assert_(s in f)
225+
f.remove(s)
226+
f.add(s)
227+
f.discard(s)
228+
216229
class TestSet(TestJointOps):
217230
thetype = set
218231

0 commit comments

Comments
 (0)