Here's something interesting:
$ gdb python
...
(gdb) run crash.py
...
Thread 1 "python" received signal SIGSEGV, Segmentation fault.
0x00007ffff745338b in ?? () from /usr/lib/libpython3.6m.so.1.0
(gdb) bt
from /usr/lib/libpython3.6m.so.1.0
from /usr/lib/libpython3.6m.so.1.0
from /usr/lib/libpython3.6m.so.1.0
from /usr/lib/libpython3.6m.so.1.0
from /usr/lib/libpython3.6m.so.1.0
from /usr/lib/libpython3.6m.so.1.0
from /usr/lib/libpython3.6m.so.1.0
from /usr/lib/libpython3.6m.so.1.0
from /usr/lib/libpython3.6m.so.1.0
from /usr/lib/libpython3.6m.so.1.0
from /usr/lib/libpython3.6m.so.1.0
from /usr/lib/libpython3.6m.so.1.0
from /usr/lib/libpython3.6m.so.1.0
from /usr/lib/libpython3.6m.so.1.0
from /usr/lib/libpython3.6m.so.1.0
3.6m.so.1.0
from /usr/lib/libpython3.6m.so.1.0
from /usr/lib/libpython3.6m.so.1.0
Watch the challenges PyErr_Displayand PyTraceBack_Print. It looks like Python was trying to show the error, but crashed in the process. Indeed, this is not a failure:
try:
intbitset([x for x in arr])
except Exception as ex:
print(repr(ex))
Rather, it outputs the following:
ValueError('retrieving integers from rhs is impossible: invalid index to scalar variable.')
, intbitset.__cinit__. , __cinit__ Cython.
, gen_arrtype_subscript C. :
>>> import numpy as np
>>> arr = np.array([1,2,3,4,5])
>>> arr[0][0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: invalid index to scalar variable.
, intbitset , :
tuple_of_tuples = rhs and hasattr(rhs, '__getitem__') and hasattr(rhs[0], '__getitem__')
, (numpy.int64 ) __getitem__, , . , intbitset , , __getitem__.
, , , intbitset(x for x in arr): __getitem__, intbitset . intbitset(arr), tuple_of_tuples arr bool:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
numpy ( , bool), , .
, invalid index to scalar segfault, truth value of an array ? , raise ValueError() , , , Undefined , , .
, intbitset - , __cinit__. Cython, , .