Description
Crash report
The following code defines a class Myset, then we instance the class and make union and isdisjoint operation. It causes segfault on CPython 3.12.0a0 (Master branch), while it triggers RecursionError on previous versions as expected.
from collections.abc import Set
class MySet(Set):
def __init__(a, itr):
a.contents = a
def __contains__(a, x):
return a in a.contents
def __iter__(a):
return iter(a.contents)
def __len__(a):
return len([a for a in a.contents])
s1 = MySet((1, 2, 3))
s2 = MySet((3, 4, 5))
# s1 = s2 & s2 //crash, segmentation fault
s1.isdisjoint(s2) // also crash, segmentation fault
Error messages
Error message for CPython Python 3.12.0a0:
Segmentation fault (core dumped)
Error message for other versions of CPython: Python 3.7.12,Python 3.8.12,Python 3.9.0,Python 3.10.1,Python 3.11.0a7+
Traceback (most recent call last):
File "/error/test_arithmetic_Set.py", line 20, in
s1.isdisjoint(s2)
^^^^^^^^^^^^^^^^^
File "", line 594, in isdisjoint
File "/error/test_arithmetic_Set.py", line 12, in iter
return iter(a.contents)
^^^^^^^^^^^^^^^^
File "/error/test_arithmetic_Set.py", line 12, in iter
return iter(a.contents)
^^^^^^^^^^^^^^^^
File "/error/test_arithmetic_Set.py", line 12, in iter
return iter(a.contents)
^^^^^^^^^^^^^^^^
[Previous line repeated 988 more times]
RecursionError: maximum recursion depth exceeded
Your environment
Python 3.12.0a0 (main, Sep 6 2022, 20:37:56) [GCC 7.5.0] on linux