Skip to content

Commit f5e29f4

Browse files
miss-islingtonkoyuki7wAlexWaygood
authored
[3.11] gh-101100: Docs: Fix references to several numeric dunders (GH-106278) (#106282)
gh-101100: Docs: Fix references to several numeric dunders (GH-106278) (cherry picked from commit a8ae739) Co-authored-by: F3eQnxN3RriK <[email protected]> Co-authored-by: Alex Waygood <[email protected]>
1 parent 8623812 commit f5e29f4

File tree

6 files changed

+45
-45
lines changed

6 files changed

+45
-45
lines changed

Doc/c-api/complex.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ Complex Numbers as Python Objects
127127
128128
Return the :c:type:`Py_complex` value of the complex number *op*.
129129
130-
If *op* is not a Python complex number object but has a :meth:`__complex__`
130+
If *op* is not a Python complex number object but has a :meth:`~object.__complex__`
131131
method, this method will first be called to convert *op* to a Python complex
132-
number object. If ``__complex__()`` is not defined then it falls back to
133-
:meth:`__float__`. If ``__float__()`` is not defined then it falls back
134-
to :meth:`__index__`. Upon failure, this method returns ``-1.0`` as a real
132+
number object. If :meth:`!__complex__` is not defined then it falls back to
133+
:meth:`~object.__float__`. If :meth:`!__float__` is not defined then it falls back
134+
to :meth:`~object.__index__`. Upon failure, this method returns ``-1.0`` as a real
135135
value.
136136
137137
.. versionchanged:: 3.8
138-
Use :meth:`__index__` if available.
138+
Use :meth:`~object.__index__` if available.

Doc/c-api/float.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ Floating Point Objects
4545
.. c:function:: double PyFloat_AsDouble(PyObject *pyfloat)
4646
4747
Return a C :c:expr:`double` representation of the contents of *pyfloat*. If
48-
*pyfloat* is not a Python floating point object but has a :meth:`__float__`
48+
*pyfloat* is not a Python floating point object but has a :meth:`~object.__float__`
4949
method, this method will first be called to convert *pyfloat* into a float.
50-
If ``__float__()`` is not defined then it falls back to :meth:`__index__`.
50+
If :meth:`!__float__` is not defined then it falls back to :meth:`~object.__index__`.
5151
This method returns ``-1.0`` upon failure, so one should call
5252
:c:func:`PyErr_Occurred` to check for errors.
5353
5454
.. versionchanged:: 3.8
55-
Use :meth:`__index__` if available.
55+
Use :meth:`~object.__index__` if available.
5656
5757
5858
.. c:function:: double PyFloat_AS_DOUBLE(PyObject *pyfloat)

Doc/c-api/long.rst

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
120120
single: OverflowError (built-in exception)
121121
122122
Return a C :c:expr:`long` representation of *obj*. If *obj* is not an
123-
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
123+
instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` method
124124
(if present) to convert it to a :c:type:`PyLongObject`.
125125
126126
Raise :exc:`OverflowError` if the value of *obj* is out of range for a
@@ -129,16 +129,16 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
129129
Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
130130
131131
.. versionchanged:: 3.8
132-
Use :meth:`__index__` if available.
132+
Use :meth:`~object.__index__` if available.
133133
134134
.. versionchanged:: 3.10
135-
This function will no longer use :meth:`__int__`.
135+
This function will no longer use :meth:`~object.__int__`.
136136
137137
138138
.. c:function:: long PyLong_AsLongAndOverflow(PyObject *obj, int *overflow)
139139
140140
Return a C :c:expr:`long` representation of *obj*. If *obj* is not an
141-
instance of :c:type:`PyLongObject`, first call its :meth:`__index__`
141+
instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__`
142142
method (if present) to convert it to a :c:type:`PyLongObject`.
143143
144144
If the value of *obj* is greater than :const:`LONG_MAX` or less than
@@ -149,10 +149,10 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
149149
Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
150150
151151
.. versionchanged:: 3.8
152-
Use :meth:`__index__` if available.
152+
Use :meth:`~object.__index__` if available.
153153
154154
.. versionchanged:: 3.10
155-
This function will no longer use :meth:`__int__`.
155+
This function will no longer use :meth:`~object.__int__`.
156156
157157
158158
.. c:function:: long long PyLong_AsLongLong(PyObject *obj)
@@ -161,7 +161,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
161161
single: OverflowError (built-in exception)
162162
163163
Return a C :c:expr:`long long` representation of *obj*. If *obj* is not an
164-
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
164+
instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` method
165165
(if present) to convert it to a :c:type:`PyLongObject`.
166166
167167
Raise :exc:`OverflowError` if the value of *obj* is out of range for a
@@ -170,16 +170,16 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
170170
Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
171171
172172
.. versionchanged:: 3.8
173-
Use :meth:`__index__` if available.
173+
Use :meth:`~object.__index__` if available.
174174
175175
.. versionchanged:: 3.10
176-
This function will no longer use :meth:`__int__`.
176+
This function will no longer use :meth:`~object.__int__`.
177177
178178
179179
.. c:function:: long long PyLong_AsLongLongAndOverflow(PyObject *obj, int *overflow)
180180
181181
Return a C :c:expr:`long long` representation of *obj*. If *obj* is not an
182-
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
182+
instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` method
183183
(if present) to convert it to a :c:type:`PyLongObject`.
184184
185185
If the value of *obj* is greater than :const:`LLONG_MAX` or less than
@@ -192,10 +192,10 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
192192
.. versionadded:: 3.2
193193
194194
.. versionchanged:: 3.8
195-
Use :meth:`__index__` if available.
195+
Use :meth:`~object.__index__` if available.
196196
197197
.. versionchanged:: 3.10
198-
This function will no longer use :meth:`__int__`.
198+
This function will no longer use :meth:`~object.__int__`.
199199
200200
201201
.. c:function:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong)
@@ -266,7 +266,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
266266
.. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *obj)
267267
268268
Return a C :c:expr:`unsigned long` representation of *obj*. If *obj* is not
269-
an instance of :c:type:`PyLongObject`, first call its :meth:`__index__`
269+
an instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__`
270270
method (if present) to convert it to a :c:type:`PyLongObject`.
271271
272272
If the value of *obj* is out of range for an :c:expr:`unsigned long`,
@@ -276,17 +276,17 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
276276
disambiguate.
277277
278278
.. versionchanged:: 3.8
279-
Use :meth:`__index__` if available.
279+
Use :meth:`~object.__index__` if available.
280280
281281
.. versionchanged:: 3.10
282-
This function will no longer use :meth:`__int__`.
282+
This function will no longer use :meth:`~object.__int__`.
283283
284284
285285
.. c:function:: unsigned long long PyLong_AsUnsignedLongLongMask(PyObject *obj)
286286
287287
Return a C :c:expr:`unsigned long long` representation of *obj*. If *obj*
288288
is not an instance of :c:type:`PyLongObject`, first call its
289-
:meth:`__index__` method (if present) to convert it to a
289+
:meth:`~object.__index__` method (if present) to convert it to a
290290
:c:type:`PyLongObject`.
291291
292292
If the value of *obj* is out of range for an :c:expr:`unsigned long long`,
@@ -296,10 +296,10 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
296296
to disambiguate.
297297
298298
.. versionchanged:: 3.8
299-
Use :meth:`__index__` if available.
299+
Use :meth:`~object.__index__` if available.
300300
301301
.. versionchanged:: 3.10
302-
This function will no longer use :meth:`__int__`.
302+
This function will no longer use :meth:`~object.__int__`.
303303
304304
305305
.. c:function:: double PyLong_AsDouble(PyObject *pylong)

Doc/library/cmath.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
This module provides access to mathematical functions for complex numbers. The
1010
functions in this module accept integers, floating-point numbers or complex
1111
numbers as arguments. They will also accept any Python object that has either a
12-
:meth:`__complex__` or a :meth:`__float__` method: these methods are used to
12+
:meth:`~object.__complex__` or a :meth:`~object.__float__` method: these methods are used to
1313
convert the object to a complex or floating-point number, respectively, and
1414
the function is then applied to the result of the conversion.
1515

Doc/library/functions.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ are always available. They are listed here in alphabetical order.
122122

123123
Convert an integer number to a binary string prefixed with "0b". The result
124124
is a valid Python expression. If *x* is not a Python :class:`int` object, it
125-
has to define an :meth:`__index__` method that returns an integer. Some
125+
has to define an :meth:`~object.__index__` method that returns an integer. Some
126126
examples:
127127

128128
>>> bin(3)
@@ -383,9 +383,9 @@ are always available. They are listed here in alphabetical order.
383383
``0j``.
384384

385385
For a general Python object ``x``, ``complex(x)`` delegates to
386-
``x.__complex__()``. If ``__complex__()`` is not defined then it falls back
387-
to :meth:`__float__`. If ``__float__()`` is not defined then it falls back
388-
to :meth:`__index__`.
386+
``x.__complex__()``. If :meth:`~object.__complex__` is not defined then it falls back
387+
to :meth:`~object.__float__`. If :meth:`!__float__` is not defined then it falls back
388+
to :meth:`~object.__index__`.
389389

390390
.. note::
391391

@@ -400,8 +400,8 @@ are always available. They are listed here in alphabetical order.
400400
Grouping digits with underscores as in code literals is allowed.
401401

402402
.. versionchanged:: 3.8
403-
Falls back to :meth:`__index__` if :meth:`__complex__` and
404-
:meth:`__float__` are not defined.
403+
Falls back to :meth:`~object.__index__` if :meth:`~object.__complex__` and
404+
:meth:`~object.__float__` are not defined.
405405

406406

407407
.. function:: delattr(object, name)
@@ -680,8 +680,8 @@ are always available. They are listed here in alphabetical order.
680680
float, an :exc:`OverflowError` will be raised.
681681

682682
For a general Python object ``x``, ``float(x)`` delegates to
683-
``x.__float__()``. If ``__float__()`` is not defined then it falls back
684-
to :meth:`__index__`.
683+
``x.__float__()``. If :meth:`~object.__float__` is not defined then it falls back
684+
to :meth:`~object.__index__`.
685685

686686
If no argument is given, ``0.0`` is returned.
687687

@@ -707,7 +707,7 @@ are always available. They are listed here in alphabetical order.
707707
*x* is now a positional-only parameter.
708708

709709
.. versionchanged:: 3.8
710-
Falls back to :meth:`__index__` if :meth:`__float__` is not defined.
710+
Falls back to :meth:`~object.__index__` if :meth:`~object.__float__` is not defined.
711711

712712

713713
.. index::
@@ -821,7 +821,7 @@ are always available. They are listed here in alphabetical order.
821821

822822
Convert an integer number to a lowercase hexadecimal string prefixed with
823823
"0x". If *x* is not a Python :class:`int` object, it has to define an
824-
:meth:`__index__` method that returns an integer. Some examples:
824+
:meth:`~object.__index__` method that returns an integer. Some examples:
825825

826826
>>> hex(255)
827827
'0xff'
@@ -892,9 +892,9 @@ are always available. They are listed here in alphabetical order.
892892
int(x, base=10)
893893

894894
Return an integer object constructed from a number or string *x*, or return
895-
``0`` if no arguments are given. If *x* defines :meth:`__int__`,
896-
``int(x)`` returns ``x.__int__()``. If *x* defines :meth:`__index__`,
897-
it returns ``x.__index__()``. If *x* defines :meth:`__trunc__`,
895+
``0`` if no arguments are given. If *x* defines :meth:`~object.__int__`,
896+
``int(x)`` returns ``x.__int__()``. If *x* defines :meth:`~object.__index__`,
897+
it returns ``x.__index__()``. If *x* defines :meth:`~object.__trunc__`,
898898
it returns ``x.__trunc__()``.
899899
For floating point numbers, this truncates towards zero.
900900

@@ -931,10 +931,10 @@ are always available. They are listed here in alphabetical order.
931931
*x* is now a positional-only parameter.
932932

933933
.. versionchanged:: 3.8
934-
Falls back to :meth:`__index__` if :meth:`__int__` is not defined.
934+
Falls back to :meth:`~object.__index__` if :meth:`~object.__int__` is not defined.
935935

936936
.. versionchanged:: 3.11
937-
The delegation to :meth:`__trunc__` is deprecated.
937+
The delegation to :meth:`~object.__trunc__` is deprecated.
938938

939939
.. versionchanged:: 3.11
940940
:class:`int` string inputs and string representations can be limited to
@@ -1137,7 +1137,7 @@ are always available. They are listed here in alphabetical order.
11371137

11381138
Convert an integer number to an octal string prefixed with "0o". The result
11391139
is a valid Python expression. If *x* is not a Python :class:`int` object, it
1140-
has to define an :meth:`__index__` method that returns an integer. For
1140+
has to define an :meth:`~object.__index__` method that returns an integer. For
11411141
example:
11421142

11431143
>>> oct(8)

Doc/library/struct.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,11 @@ Notes:
266266

267267
(2)
268268
When attempting to pack a non-integer using any of the integer conversion
269-
codes, if the non-integer has a :meth:`__index__` method then that method is
269+
codes, if the non-integer has a :meth:`~object.__index__` method then that method is
270270
called to convert the argument to an integer before packing.
271271

272272
.. versionchanged:: 3.2
273-
Added use of the :meth:`__index__` method for non-integers.
273+
Added use of the :meth:`~object.__index__` method for non-integers.
274274

275275
(3)
276276
The ``'n'`` and ``'N'`` conversion codes are only available for the native

0 commit comments

Comments
 (0)