mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
gh-101100: Docs: Fix references to several numeric dunders (#106278)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
319de0b578
commit
a8ae73965b
6 changed files with 45 additions and 45 deletions
|
@ -127,12 +127,12 @@ Complex Numbers as Python Objects
|
|||
|
||||
Return the :c:type:`Py_complex` value of the complex number *op*.
|
||||
|
||||
If *op* is not a Python complex number object but has a :meth:`__complex__`
|
||||
If *op* is not a Python complex number object but has a :meth:`~object.__complex__`
|
||||
method, this method will first be called to convert *op* to a Python complex
|
||||
number object. If ``__complex__()`` is not defined then it falls back to
|
||||
:meth:`__float__`. If ``__float__()`` is not defined then it falls back
|
||||
to :meth:`__index__`. Upon failure, this method returns ``-1.0`` as a real
|
||||
number object. If :meth:`!__complex__` is not defined then it falls back to
|
||||
:meth:`~object.__float__`. If :meth:`!__float__` is not defined then it falls back
|
||||
to :meth:`~object.__index__`. Upon failure, this method returns ``-1.0`` as a real
|
||||
value.
|
||||
|
||||
.. versionchanged:: 3.8
|
||||
Use :meth:`__index__` if available.
|
||||
Use :meth:`~object.__index__` if available.
|
||||
|
|
|
@ -45,14 +45,14 @@ Floating Point Objects
|
|||
.. c:function:: double PyFloat_AsDouble(PyObject *pyfloat)
|
||||
|
||||
Return a C :c:expr:`double` representation of the contents of *pyfloat*. If
|
||||
*pyfloat* is not a Python floating point object but has a :meth:`__float__`
|
||||
*pyfloat* is not a Python floating point object but has a :meth:`~object.__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__`.
|
||||
If :meth:`!__float__` is not defined then it falls back to :meth:`~object.__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.
|
||||
Use :meth:`~object.__index__` if available.
|
||||
|
||||
|
||||
.. c:function:: double PyFloat_AS_DOUBLE(PyObject *pyfloat)
|
||||
|
|
|
@ -121,7 +121,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
|
|||
single: OverflowError (built-in exception)
|
||||
|
||||
Return a C :c:expr:`long` representation of *obj*. If *obj* is not an
|
||||
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
|
||||
instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` 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
|
||||
|
@ -130,16 +130,16 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
|
|||
Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
|
||||
|
||||
.. versionchanged:: 3.8
|
||||
Use :meth:`__index__` if available.
|
||||
Use :meth:`~object.__index__` if available.
|
||||
|
||||
.. versionchanged:: 3.10
|
||||
This function will no longer use :meth:`__int__`.
|
||||
This function will no longer use :meth:`~object.__int__`.
|
||||
|
||||
|
||||
.. c:function:: long PyLong_AsLongAndOverflow(PyObject *obj, int *overflow)
|
||||
|
||||
Return a C :c:expr:`long` representation of *obj*. If *obj* is not an
|
||||
instance of :c:type:`PyLongObject`, first call its :meth:`__index__`
|
||||
instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__`
|
||||
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
|
||||
|
@ -150,10 +150,10 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
|
|||
Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
|
||||
|
||||
.. versionchanged:: 3.8
|
||||
Use :meth:`__index__` if available.
|
||||
Use :meth:`~object.__index__` if available.
|
||||
|
||||
.. versionchanged:: 3.10
|
||||
This function will no longer use :meth:`__int__`.
|
||||
This function will no longer use :meth:`~object.__int__`.
|
||||
|
||||
|
||||
.. c:function:: long long PyLong_AsLongLong(PyObject *obj)
|
||||
|
@ -162,7 +162,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
|
|||
single: OverflowError (built-in exception)
|
||||
|
||||
Return a C :c:expr:`long long` representation of *obj*. If *obj* is not an
|
||||
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
|
||||
instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` 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
|
||||
|
@ -171,16 +171,16 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
|
|||
Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
|
||||
|
||||
.. versionchanged:: 3.8
|
||||
Use :meth:`__index__` if available.
|
||||
Use :meth:`~object.__index__` if available.
|
||||
|
||||
.. versionchanged:: 3.10
|
||||
This function will no longer use :meth:`__int__`.
|
||||
This function will no longer use :meth:`~object.__int__`.
|
||||
|
||||
|
||||
.. c:function:: long long PyLong_AsLongLongAndOverflow(PyObject *obj, int *overflow)
|
||||
|
||||
Return a C :c:expr:`long long` representation of *obj*. If *obj* is not an
|
||||
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
|
||||
instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` method
|
||||
(if present) to convert it to a :c:type:`PyLongObject`.
|
||||
|
||||
If the value of *obj* is greater than :const:`LLONG_MAX` or less than
|
||||
|
@ -193,10 +193,10 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
|
|||
.. versionadded:: 3.2
|
||||
|
||||
.. versionchanged:: 3.8
|
||||
Use :meth:`__index__` if available.
|
||||
Use :meth:`~object.__index__` if available.
|
||||
|
||||
.. versionchanged:: 3.10
|
||||
This function will no longer use :meth:`__int__`.
|
||||
This function will no longer use :meth:`~object.__int__`.
|
||||
|
||||
|
||||
.. c:function:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)
|
||||
|
@ -267,7 +267,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
|
|||
.. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *obj)
|
||||
|
||||
Return a C :c:expr:`unsigned long` representation of *obj*. If *obj* is not
|
||||
an instance of :c:type:`PyLongObject`, first call its :meth:`__index__`
|
||||
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 value of *obj* is out of range for an :c:expr:`unsigned long`,
|
||||
|
@ -277,17 +277,17 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
|
|||
disambiguate.
|
||||
|
||||
.. versionchanged:: 3.8
|
||||
Use :meth:`__index__` if available.
|
||||
Use :meth:`~object.__index__` if available.
|
||||
|
||||
.. versionchanged:: 3.10
|
||||
This function will no longer use :meth:`__int__`.
|
||||
This function will no longer use :meth:`~object.__int__`.
|
||||
|
||||
|
||||
.. c:function:: unsigned long long PyLong_AsUnsignedLongLongMask(PyObject *obj)
|
||||
|
||||
Return a C :c:expr:`unsigned long long` representation of *obj*. If *obj*
|
||||
is not an instance of :c:type:`PyLongObject`, first call its
|
||||
:meth:`__index__` method (if present) to convert it to a
|
||||
:meth:`~object.__index__` method (if present) to convert it to a
|
||||
:c:type:`PyLongObject`.
|
||||
|
||||
If the value of *obj* is out of range for an :c:expr:`unsigned long long`,
|
||||
|
@ -297,10 +297,10 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
|
|||
to disambiguate.
|
||||
|
||||
.. versionchanged:: 3.8
|
||||
Use :meth:`__index__` if available.
|
||||
Use :meth:`~object.__index__` if available.
|
||||
|
||||
.. versionchanged:: 3.10
|
||||
This function will no longer use :meth:`__int__`.
|
||||
This function will no longer use :meth:`~object.__int__`.
|
||||
|
||||
|
||||
.. c:function:: double PyLong_AsDouble(PyObject *pylong)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue