summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2012-06-23 09:49:36 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2012-06-23 09:49:36 (GMT)
commit766e62266e72d7586e8cbf74213a3935a974ef14 (patch)
treeb78664c04f0b16d39e4b0a10bb43a94cd7fc4572
parent2f92e54507cd4a76978133c10bf32cbdef90cd37 (diff)
parent0a22924d52fd3b57d214f64f6f16e4d7fc111888 (diff)
downloadcpython-766e62266e72d7586e8cbf74213a3935a974ef14.zip
cpython-766e62266e72d7586e8cbf74213a3935a974ef14.tar.gz
cpython-766e62266e72d7586e8cbf74213a3935a974ef14.tar.bz2
Issue #12965: Merge from 3.2
-rw-r--r--Doc/c-api/long.rst29
1 files changed, 16 insertions, 13 deletions
diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst
index 4c295fa..ab6dac2 100644
--- a/Doc/c-api/long.rst
+++ b/Doc/c-api/long.rst
@@ -122,26 +122,29 @@ All integers are implemented as "long" integer objects of arbitrary size.
.. XXX alias PyLong_AS_LONG (for now)
-.. c:function:: long PyLong_AsLong(PyObject *pylong)
+.. c:function:: long PyLong_AsLong(PyObject *obj)
.. index::
single: LONG_MAX
single: OverflowError (built-in exception)
- Return a C :c:type:`long` representation of the contents of *pylong*. If
- *pylong* is greater than :const:`LONG_MAX`, raise an :exc:`OverflowError`,
- and return -1. Convert non-long objects automatically to long first,
- and return -1 if that raises exceptions.
+ Return a C :c:type:`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`.
-.. c:function:: long PyLong_AsLongAndOverflow(PyObject *pylong, int *overflow)
+ Raise :exc:`OverflowError` if the value of *obj* is out of range for a
+ :c:type:`long`.
- Return a C :c:type:`long` representation of the contents of
- *pylong*. If *pylong* is greater than :const:`LONG_MAX` or less
- than :const:`LONG_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:: long PyLong_AsLongAndOverflow(PyObject *obj, int *overflow)
+
+ Return a C :c:type:`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:`LONG_MAX` or less than
+ :const:`LONG_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.
.. c:function:: PY_LONG_LONG PyLong_AsLongLongAndOverflow(PyObject *pylong, int *overflow)