Christopher Barker, 13.04.2010 18:34: > so, can I now do: > > cdef f( int x ): > .... > > def myfunc(x, y): > > cdef int z > ... > z = x > ... > f( z ) > > and pass in None for x, and have f( z ) get None? If so, might it crash? > and if not, where is it caught?
'f' is a cdef function, so the *caller* sees the type of the argument and tries the conversion. Since this fails, the exception will be raised from within myfunc() and occur in the code line that calls f(). > I guess it comes down to this, from this newbie's perspective: > > If I type a variable, the code should not crash if I pass in something > else, anything else, it should coerce or fail with an exception, unless > I _explicitly_ tell Cython that it could be something else, in which > case, I'd better have written the code to handle that. That's the theory. However, None is special, and you actually *want* None to be allowed in most cases, except for function input values. You certainly want to be able to set a typed Python object variable to None to delete the reference it contains. >> Anyway: It's 2 vs. 2 at this point > > I really don't care if anyone is counting my "vote" or not, this sort of > decision shouldn't be made by majority choice anyway. Agreed. Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
