Hi,

Lisandro Dalcin wrote:
> Core CPython is not consistent about this. What should we do in
> Cython? Should we report this to Python-Dev?
> 
> Long story:
> 
> In core CPython (svn trunk), at Objects/longobjects.c, you should see
> that in almost all cases OverflowError is raise. But see this one:
> 
> int
> _PyLong_AsByteArray(PyLongObject* v,
>                   unsigned char* bytes, size_t n,
>                   int little_endian, int is_signed)
> {
> <...>
>               if (!is_signed) {
>                       PyErr_SetString(PyExc_TypeError,
>                               "can't convert negative long to unsigned");
>                       return -1;
>               }
> <...>
> }

Raising an OverflowError sounds like the right thing. If CPython raises it
in almost all cases, it's ok if Cython does that, too.

Still, asking on python-dev would allow them to take a decision and maybe
even fix the above discrepancy.

Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to