From b77c6c65c06a19740fe2f22004959a4aa1eaba5d Mon Sep 17 00:00:00 2001 From: Stefan Krah Date: Mon, 12 Sep 2011 16:22:47 +0200 Subject: [PATCH] Issue #12963: PyLong_AsSize_t() now returns (size_t)-1 in all error cases. --- Objects/longobject.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Objects/longobject.c b/Objects/longobject.c index 552f8f0b898..a0b16a66f2d 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -525,8 +525,8 @@ PyLong_AsUnsignedLong(PyObject *vv) return x; } -/* Get a C unsigned long int from a long int object. - Returns -1 and sets an error condition if overflow occurs. */ +/* Get a C size_t from a long int object. Returns (size_t)-1 and sets + an error condition if overflow occurs. */ size_t PyLong_AsSize_t(PyObject *vv) @@ -562,7 +562,7 @@ PyLong_AsSize_t(PyObject *vv) if ((x >> PyLong_SHIFT) != prev) { PyErr_SetString(PyExc_OverflowError, "Python int too large to convert to C size_t"); - return (unsigned long) -1; + return (size_t) -1; } } return x;