Keep PyLong_AsLongAndOverflow documentation and implementation in sync
between py3k and trunk;  merge new tests from trunk to py3k.
(See issue #7528.)
diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst
index 19d65b8..083fe8b 100644
--- a/Doc/c-api/long.rst
+++ b/Doc/c-api/long.rst
@@ -121,10 +121,13 @@
 
 .. cfunction:: long PyLong_AsLongAndOverflow(PyObject *pylong, int* overflow)
 
-   Return a C :ctype:`long` representation of the contents of *pylong*.  If
-   *pylong* is greater than :const:`LONG_MAX`, return -1 and
-   set `*overflow` to 1 (for overflow) or -1 (for underflow).
-   If an exception is set because of type errors, also return -1.
+   Return a C :ctype:`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``.
 
 
 .. cfunction:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)