]> granicus.if.org Git - python/commitdiff
Issue #12965: Clean up C-API docs for PyLong_AsLongLong(AndOverflow); clarify that...
authorMark Dickinson <mdickinson@enthought.com>
Sat, 23 Jun 2012 10:14:22 +0000 (11:14 +0100)
committerMark Dickinson <mdickinson@enthought.com>
Sat, 23 Jun 2012 10:14:22 +0000 (11:14 +0100)
Doc/c-api/long.rst

index 526a87d94b8113e920ecd5b3640abb2b927ac3de..e428da19c4915575ce0f3a49ab983f4e50508a33 100644 (file)
@@ -121,6 +121,7 @@ All integers are implemented as "long" integer objects of arbitrary size.
    Raise :exc:`OverflowError` if the value of *obj* is out of range for a
    :c:type:`long`.
 
+
 .. c:function:: long PyLong_AsLongAndOverflow(PyObject *obj, int *overflow)
 
    Return a C :c:type:`long` representation of *obj*.  If *obj* is not an
@@ -133,15 +134,29 @@ All integers are implemented as "long" integer objects of arbitrary size.
    occurs set *\*overflow* to ``0`` and return ``-1`` as usual.
 
 
-.. c:function:: PY_LONG_LONG PyLong_AsLongLongAndOverflow(PyObject *pylong, int *overflow)
+.. c:function:: PY_LONG_LONG PyLong_AsLongLong(PyObject *obj)
+
+   .. index::
+      single: OverflowError (built-in exception)
+
+   Return a C :c:type:`long long` representation of *obj*.  If *obj* is not an
+   instance of :c:type:`PyLongObject`, first call its :meth:`__int__` method
+   (if present) to convert it to a :c:type:`PyLongObject`.
+
+   Raise :exc:`OverflowError` if the value of *obj* is out of range for a
+   :c:type:`long`.
+
 
-   Return a C :c:type:`long long` representation of the contents of
-   *pylong*.  If *pylong* is greater than :const:`PY_LLONG_MAX` or less
-   than :const:`PY_LLONG_MIN`, set *\*overflow* to ``1`` or ``-1``,
-   respectively, and return ``-1``; otherwise, set *\*overflow* to
-   ``0``.  If any other exception occurs (for example a TypeError or
-   MemoryError), then ``-1`` will be returned and *\*overflow* will
-   be ``0``.
+.. c:function:: PY_LONG_LONG PyLong_AsLongLongAndOverflow(PyObject *obj, int *overflow)
+
+   Return a C :c:type:`long long` representation of *obj*.  If *obj* is not an
+   instance of :c:type:`PyLongObject`, first call its :meth:`__int__` method
+   (if present) to convert it to a :c:type:`PyLongObject`.
+
+   If the value of *obj* is greater than :const:`PY_LLONG_MAX` or less than
+   :const:`PY_LLONG_MIN`, set *\*overflow* to ``1`` or ``-1``, respectively,
+   and return ``-1``; otherwise, set *\*overflow* to ``0``.  If any other
+   exception occurs set *\*overflow* to ``0`` and return ``-1`` as usual.
 
    .. versionadded:: 3.2
 
@@ -175,16 +190,6 @@ All integers are implemented as "long" integer objects of arbitrary size.
    :exc:`OverflowError` is raised.
 
 
-.. c:function:: PY_LONG_LONG PyLong_AsLongLong(PyObject *pylong)
-
-   .. index::
-      single: OverflowError (built-in exception)
-
-   Return a C :c:type:`long long` from a Python integer.  If *pylong*
-   cannot be represented as a :c:type:`long long`, an
-   :exc:`OverflowError` is raised and ``-1`` is returned.
-
-
 .. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(PyObject *pylong)
 
    .. index::