[Python-checkins] cpython: Issue #12965: Fix some inaccurate comments in Objects/longobject.c. Thanks

mark.dickinson python-checkins at python.org
Sun Oct 23 21:47:41 CEST 2011


http://hg.python.org/cpython/rev/d4839fea4a5a
changeset:   73075:d4839fea4a5a
user:        Mark Dickinson <mdickinson at enthought.com>
date:        Sun Oct 23 20:47:14 2011 +0100
summary:
  Issue #12965: Fix some inaccurate comments in Objects/longobject.c.  Thanks Stefan Krah.

files:
  Objects/longobject.c |  40 +++++++++++++++++++------------
  1 files changed, 24 insertions(+), 16 deletions(-)


diff --git a/Objects/longobject.c b/Objects/longobject.c
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -322,8 +322,15 @@
 #define PY_ABS_LONG_MIN         (0-(unsigned long)LONG_MIN)
 #define PY_ABS_SSIZE_T_MIN      (0-(size_t)PY_SSIZE_T_MIN)
 
-/* Get a C long int from a long int object.
-   Returns -1 and sets an error condition if overflow occurs. */
+/* Get a C long int from a long int object or any object that has an __int__
+   method.
+
+   On overflow, return -1 and set *overflow to 1 or -1 depending on the sign of
+   the result.  Otherwise *overflow is 0.
+
+   For other errors (e.g., TypeError), return -1 and set an error condition.
+   In this case *overflow will be 0.
+*/
 
 long
 PyLong_AsLongAndOverflow(PyObject *vv, int *overflow)
@@ -412,6 +419,9 @@
     return res;
 }
 
+/* Get a C long int from a long int object or any object that has an __int__
+   method.  Return -1 and set an error if overflow occurs. */
+
 long
 PyLong_AsLong(PyObject *obj)
 {
@@ -923,7 +933,7 @@
 
 }
 
-/* Create a new long (or int) object from a C pointer */
+/* Create a new long int object from a C pointer */
 
 PyObject *
 PyLong_FromVoidPtr(void *p)
@@ -941,15 +951,11 @@
 
 }
 
-/* Get a C pointer from a long object (or an int object in some cases) */
+/* Get a C pointer from a long int object. */
 
 void *
 PyLong_AsVoidPtr(PyObject *vv)
 {
-    /* This function will allow int or long objects. If vv is neither,
-       then the PyLong_AsLong*() functions will raise the exception:
-       PyExc_SystemError, "bad argument to internal function"
-    */
 #if SIZEOF_VOID_P <= SIZEOF_LONG
     long x;
 
@@ -1130,8 +1136,8 @@
     return (PyObject *)v;
 }
 
-/* Get a C PY_LONG_LONG int from a long int object.
-   Return -1 and set an error if overflow occurs. */
+/* Get a C long long int from a long int object or any object that has an
+   __int__ method.  Return -1 and set an error if overflow occurs. */
 
 PY_LONG_LONG
 PyLong_AsLongLong(PyObject *vv)
@@ -1287,12 +1293,14 @@
 }
 #undef IS_LITTLE_ENDIAN
 
-/* Get a C long long int from a Python long or Python int object.
-   On overflow, returns -1 and sets *overflow to 1 or -1 depending
-   on the sign of the result.  Otherwise *overflow is 0.
-
-   For other errors (e.g., type error), returns -1 and sets an error
-   condition.
+/* Get a C long long int from a long int object or any object that has an
+   __int__ method.
+
+   On overflow, return -1 and set *overflow to 1 or -1 depending on the sign of
+   the result.  Otherwise *overflow is 0.
+
+   For other errors (e.g., TypeError), return -1 and set an error condition.
+   In this case *overflow will be 0.
 */
 
 PY_LONG_LONG

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


More information about the Python-checkins mailing list