If numpy is built with NPY_RELAXED_STRIDES_DEBUG == 1, then fromiter uses the invalid strides.
import numpy as np
NPY_RELAXED_STRIDES_DEBUG = np.ones(1, np.uint8).strides[0] != 1
assert NPY_RELAXED_STRIDES_DEBUG
class MyIter:
def __length_hint__(self):
# only required to be an estimate, this is legal
return 1
def __iter__(self):
return iter([1, 2, 3])
x = np.fromiter(MyIter(), int)
# segfault
Tested on an approximation of master.