[Cython] C int division by zero

Stefan Behnel stefan_ml at behnel.de
Wed Apr 15 08:43:00 CEST 2009


Dag Sverre Seljebotn wrote:
> usually with overflows one just gets the overflowed value
> silently. With division overflow one crashes the application, which is
> IMO much worse even if it is a very rare corner case.
>
> I think we should raise OverflowError here under the same circumstances
> as ZeroDivisionError.

+1, this matches the patch Lisandro provided.

BTW, isn't there a way to catch these signals in a way that would allow us
to raise an exception instead? Catching signals isn't the hard part, I
guess, but we'd have to extract the current state and code position from
the signal handler, so that we can jump back to the right label and
continue.

As long as they don't occur, signals are a lot cheaper than doing runtime
checks all over the place.

Stefan



More information about the Cython-dev mailing list