[Cython] overflow bug?

Mark Florisson markflorisson88 at gmail.com
Tue Jul 14 20:34:52 CEST 2015


Hi,

I think this might be a bug (python 3.3 + cython 0.22.1):

    def f(term=b"12345"):

    val = int('987278186585')
    # The below line does not work, because it treats 1 as a constant integer
    # in the C code (32 bit on my machine). Using 1L does work however.
    val -= 1 << (len(term) * 8)
    return val

print(f())

This works in pure-python, but Cython generates '1 <<
__pyx_t_somevar', which I think treats the '1' as an integer (causing
it to overflow). Using '1L' works in the Cython code however (but that
may be just my platform).


Cheers,

Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cython-devel/attachments/20150714/98a092be/attachment.html>


More information about the cython-devel mailing list