chiark / gitweb /
Return `long' objects when `int' is requested but the value won't fit.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 3 May 2017 11:48:27 +0000 (12:48 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 13 May 2017 14:40:07 +0000 (15:40 +0100)
commit5779eaf1c6c738aac2227dcadb9e8c27ca22631e
treec67754a4d8fe21d293b8390319efb836c0279811
parent42d30ef60edcafe5b5f85f8c0e7d7637ed0a84fc
Return `long' objects when `int' is requested but the value won't fit.

Mostly, Python handles the error from the `int' conversion and falls
back to long, but there's something weird in iteration, where if you say

for i in ...:
  print '%d' % x

then the loop finishes and /then/ you get an exception for the overflow
from the failed conversion of x to an `int'.

Follow Python's actual behaviour: have `mp_tolong_checked' take an extra
argument indicating whether to throw an exception, and modify most of
the call sites to fall back to a conversion based on `mp_topylong'.
catacomb-python.h
ec.c
field.c
group.c
mp.c
pgen.c