[Python-checkins] cpython (3.2): Issue #12963: PyLong_AsSize_t() now returns (size_t)-1 in all error cases.

stefan.krah python-checkins at python.org
Mon Sep 12 16:27:41 CEST 2011


http://hg.python.org/cpython/rev/d14f717b5e3d
changeset:   72344:d14f717b5e3d
branch:      3.2
parent:      72337:1ab62d3b96d2
user:        Stefan Krah <skrah at bytereef.org>
date:        Mon Sep 12 16:22:47 2011 +0200
summary:
  Issue #12963: PyLong_AsSize_t() now returns (size_t)-1 in all error cases.

files:
  Objects/longobject.c |  6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)


diff --git a/Objects/longobject.c b/Objects/longobject.c
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -525,8 +525,8 @@
     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 @@
         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;

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list