]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-137368: document __index__() support for PyLong_AsInt32/64() (GH-137369...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 11 Sep 2025 09:14:03 +0000 (11:14 +0200)
committerGitHub <noreply@github.com>
Thu, 11 Sep 2025 09:14:03 +0000 (12:14 +0300)
gh-137368: document __index__() support for PyLong_AsInt32/64() (GH-137369)
(cherry picked from commit 4dd85b347fd8264453811e0873e0dffa333d9838)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Doc/c-api/long.rst

index 2d0bda76697e81c8ba411c406260ea0eddd658d7..31e2cd57034467ac3f59360e92433909454c62ec 100644 (file)
@@ -372,6 +372,10 @@ distinguished from a number.  Use :c:func:`PyErr_Occurred` to disambiguate.
    Set *\*value* to a signed C :c:expr:`int32_t` or :c:expr:`int64_t`
    representation of *obj*.
 
+   If *obj* is not an instance of :c:type:`PyLongObject`, first call its
+   :meth:`~object.__index__` method (if present) to convert it to a
+   :c:type:`PyLongObject`.
+
    If the *obj* value is out of range, raise an :exc:`OverflowError`.
 
    Set *\*value* and return ``0`` on success.