[pypy-dev] do not raise exceptions in __init__

Armin Rigo arigo at tunes.org
Sun Aug 9 10:54:54 CEST 2015


Hi Matti,

Replying to commit "614e585": "do not raise exceptions in __init__"

The __init__ can raise exceptions, it's not the problem here.  This
commit changes (only) something else: it moves around which "*" turn
into an overflow-checking multiplication, and which ones don't.  The
"*" operation in RPython, like the other common arithmetic operations,
turn by default into C code as a "*" that assumes that overflow does
not occur (and the C compiler sometimes optimizes based on this).  On
the other hand, if the "*" operation in RPython appears immediately
inside a "try: except OverflowError:" (and only in this case), then in
C it will also do the same check.

Notably, this checkin fixes this code (by removing it):

        try:
             length = support.product(shape)
        except OverflowError as e:
             ...

which after translation to C would never catch an OverflowError
occurring implicitly inside product().


A bientôt,

Armin.


More information about the pypy-dev mailing list