Commit d43facd1 authored by Stefan Behnel's avatar Stefan Behnel

disable incorrect optimisation for set.discard()

parent cd31ff67
......@@ -380,8 +380,9 @@ builtin_types_table = [
("set", "PySet_Type", [BuiltinMethod("clear", "T", "r", "PySet_Clear",
utility_code = py_set_utility_code),
BuiltinMethod("discard", "TO", "r", "PySet_Discard",
utility_code = py_set_utility_code),
# discard() and remove() have a special treatment for unhashable values
# BuiltinMethod("discard", "TO", "r", "PySet_Discard",
# utility_code = py_set_utility_code),
BuiltinMethod("add", "TO", "r", "PySet_Add",
utility_code = py_set_utility_code),
BuiltinMethod("pop", "T", "O", "PySet_Pop",
......
def set_discard():
"""
>>> sorted(set_discard())
[1, 2]
"""
s = set([1,2,3])
s.discard(3)
return s
def set_discard_missing():
"""
>>> sorted(set_discard_missing())
[1, 2, 3]
"""
s = set([1,2,3])
s.discard(4)
return s
def set_discard_set():
"""
>>> s = set_discard_set()
>>> len(s)
1
>>> sorted(s.pop())
[1, 2]
"""
s = set([frozenset([1,2]), frozenset([2,3])])
s.discard(set([2,3]))
return s
def set_remove():
"""
>>> sorted(set_remove())
[1, 2]
"""
s = set([1,2,3])
s.remove(3)
return s
def set_remove_missing():
"""
>>> sorted(set_remove_missing())
Traceback (most recent call last):
KeyError: 4
"""
s = set([1,2,3])
s.remove(4)
return s
def set_remove_set():
"""
>>> s = set_remove_set()
>>> len(s)
1
>>> sorted(s.pop())
[1, 2]
"""
s = set([frozenset([1,2]), frozenset([2,3])])
s.remove(set([2,3]))
return s
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment