Issue #12963: PyLong_AsSize_t() now returns (size_t)-1 in all error cases.

This commit is contained in:
Stefan Krah 2011-09-12 16:22:47 +02:00
parent 4165bfb6e9
commit b77c6c65c0
1 changed files with 3 additions and 3 deletions

View File

@ -525,8 +525,8 @@ PyLong_AsUnsignedLong(PyObject *vv)
return x; return x;
} }
/* Get a C unsigned long int from a long int object. /* Get a C size_t from a long int object. Returns (size_t)-1 and sets
Returns -1 and sets an error condition if overflow occurs. */ an error condition if overflow occurs. */
size_t size_t
PyLong_AsSize_t(PyObject *vv) PyLong_AsSize_t(PyObject *vv)
@ -562,7 +562,7 @@ PyLong_AsSize_t(PyObject *vv)
if ((x >> PyLong_SHIFT) != prev) { if ((x >> PyLong_SHIFT) != prev) {
PyErr_SetString(PyExc_OverflowError, PyErr_SetString(PyExc_OverflowError,
"Python int too large to convert to C size_t"); "Python int too large to convert to C size_t");
return (unsigned long) -1; return (size_t) -1;
} }
} }
return x; return x;