summaryrefslogtreecommitdiffstats
path: root/Doc/c-api/long.rst
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2012-06-23 10:14:55 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2012-06-23 10:14:55 (GMT)
commit93648f033b4da831f9412b365c10a49ead7a6937 (patch)
tree8660d9174e8de70ba4496deb78e33511dd0518a2 /Doc/c-api/long.rst
parent04e2e3f2310964bb353cc85e4ebedf2391109118 (diff)
parentf0acfeeccfdb19e20092a83e6eb7a3cb0566ba47 (diff)
downloadcpython-93648f033b4da831f9412b365c10a49ead7a6937.zip
cpython-93648f033b4da831f9412b365c10a49ead7a6937.tar.gz
cpython-93648f033b4da831f9412b365c10a49ead7a6937.tar.bz2
Issue #12965: Merge from 3.2.
Diffstat (limited to 'Doc/c-api/long.rst')
-rw-r--r--Doc/c-api/long.rst41
1 files changed, 23 insertions, 18 deletions
diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst
index ab6dac2..6d2ba3f 100644
--- a/Doc/c-api/long.rst
+++ b/Doc/c-api/long.rst
@@ -135,6 +135,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
@@ -147,15 +148,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
@@ -189,16 +204,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::