thierry-martinez/pyml

Numpy.to_bigarray causes a segfault when passed a python object with the wrong type

jonathan-laurent opened this issue · 3 comments

The following code causes a segfault:

let () =
  Py.initialize;
  Numpy.to_bigarray Float64 C_layout Py.none

Would it be possible for Numpy.to_bigarray to raise an exception instead (as is done byPy.Int.to_int for example)?

Thank you very much for reporting! This should be fixed now.

Thanks for your answer!

However, your fix only applies to the case where None is passed and indeed, the code below still segfaults:

let () =
  Py.initialize;
  Numpy.to_bigarray Float64 C_layout (Py.Int.of_int 2)

Would there be a way for Numpy.to_bigarray to check whether the passed object is indeed a numpy array?

Oops! Sorry for that. Done!