[Cython] C int division by zero
Dag Sverre Seljebotn
dagss at student.matnat.uio.no
Tue Apr 14 18:17:28 CEST 2009
I was just thinking about this:
cdef int a = 10, b = 0
print a // b
which currently gives a C exception terminating the Python interpreter.
On one hand: We have already changed division to Python behaviour (with
a speed penalty); so using the same arguments (which I won't reiterate)
it would make sense to raise a Python exception instead here.
It seems to make sense to couple this as well to the cdivision directive
and cython.cdiv function.
On the other hand: Well, all the arguments that was against changing //
to Python behaviour.
But in addition:
This is coupled with the "exception under nogil" issue that I raised in
another thread today, as one should definitely be allowed to do C
division within a nogil section.
One solution would be to work on accepting exceptions under nogil,
another one would be to require use of cdivision directive/cdiv to do
division in nogil sections.
--
Dag Sverre
More information about the Cython-dev
mailing list