Christopher Barker wrote:

> I just accidentally passed None in to a cython function that is 
> expecting a numpy array, and got a hard crash.
> 
> def none_test(np.ndarray[np.uint8_t, ndim=1, mode="c"] a):
>      return a

Variables declared as referring to extension types also
accept the value None, because you need some way of
representing a null value.

The type checking code generated for function arguments
also accepts None by default, but you can override this
by declaring the argument as "not None", e.g.

   def none_test(np.ndarray[np.uint8_t, ndim=1, mode="c"] a not None):

You will then get an exception if you try to pass None
to this function.

(In Pyrex I'm thinking about changing this so that the
default is *not* to accept None for an argument value,
because this seems to trip up a lot of people.)

-- 
Greg
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to