summaryrefslogtreecommitdiffstats
path: root/Doc/c-api/float.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/c-api/float.rst')
-rw-r--r--Doc/c-api/float.rst4
1 files changed, 4 insertions, 0 deletions
diff --git a/Doc/c-api/float.rst b/Doc/c-api/float.rst
index 8a99642..057ff52 100644
--- a/Doc/c-api/float.rst
+++ b/Doc/c-api/float.rst
@@ -47,9 +47,13 @@ Floating Point Objects
Return a C :c:type:`double` representation of the contents of *pyfloat*. If
*pyfloat* is not a Python floating point object but has a :meth:`__float__`
method, this method will first be called to convert *pyfloat* into a float.
+ If ``__float__()`` is not defined then it falls back to :meth:`__index__`.
This method returns ``-1.0`` upon failure, so one should call
:c:func:`PyErr_Occurred` to check for errors.
+ .. versionchanged:: 3.8
+ Use :meth:`__index__` if available.
+
.. c:function:: double PyFloat_AS_DOUBLE(PyObject *pyfloat)