[Python-Dev] negative PyLong integer -> unsigned integer, TypeError or OverflowError? (original) (raw)
Lisandro Dalcin dalcinl at gmail.com
Fri Feb 6 22:04:44 CET 2009
- Previous message: [Python-Dev] Summary of Python tracker Issues
- Next message: [Python-Dev] negative PyLong integer -> unsigned integer, TypeError or OverflowError?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
While hacking on Cython to make it recognize 'size_t' as a pre-defined C integral type, I've found somethig that seems to be (pretty small) inconsistency.
At Objects/longobject.c, you should see that in almost all cases OverflowError is raised when a unsigned integral is requested from a negative PyLong. However, 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; } <...> }
Does it make sense to change that code to raise OverflowError?
-- Lisandro Dalcín
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC) Instituto de Desarrollo Tecnológico para la Industria Química (INTEC) Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET) PTLC - Güemes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594
- Previous message: [Python-Dev] Summary of Python tracker Issues
- Next message: [Python-Dev] negative PyLong integer -> unsigned integer, TypeError or OverflowError?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]