Skip to content

Commit d6a5a30

Browse files
miss-islingtonkoyuki7wAlexWaygood
authored
[3.12] pythongh-101100: Docs: Fix references to several numeric dunders (pythonGH-106278) (python#106281)
pythongh-101100: Docs: Fix references to several numeric dunders (pythonGH-106278) (cherry picked from commit a8ae739) Co-authored-by: F3eQnxN3RriK <[email protected]> Co-authored-by: Alex Waygood <[email protected]>
1 parent 7a1b946 commit d6a5a30

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
@@ -121,7 +121,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
121121
single: OverflowError (built-in exception)
122122
123123
Return a C :c:expr:`long` representation of *obj*. If *obj* is not an
124-
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
124+
instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` method
125125
(if present) to convert it to a :c:type:`PyLongObject`.
126126
127127
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.
130130
Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
131131
132132
.. versionchanged:: 3.8
133-
Use :meth:`__index__` if available.
133+
Use :meth:`~object.__index__` if available.
134134
135135
.. versionchanged:: 3.10
136-
This function will no longer use :meth:`__int__`.
136+
This function will no longer use :meth:`~object.__int__`.
137137
138138
139139
.. c:function:: long PyLong_AsLongAndOverflow(PyObject *obj, int *overflow)
140140
141141
Return a C :c:expr:`long` representation of *obj*. If *obj* is not an
142-
instance of :c:type:`PyLongObject`, first call its :meth:`__index__`
142+
instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__`
143143
method (if present) to convert it to a :c:type:`PyLongObject`.
144144
145145
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.
150150
Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
151151
152152
.. versionchanged:: 3.8
153-
Use :meth:`__index__` if available.
153+
Use :meth:`~object.__index__` if available.
154154
155155
.. versionchanged:: 3.10
156-
This function will no longer use :meth:`__int__`.
156+
This function will no longer use :meth:`~object.__int__`.
157157
158158
159159
.. c:function:: long long PyLong_AsLongLong(PyObject *obj)
@@ -162,7 +162,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
162162
single: OverflowError (built-in exception)
163163
164164
Return a C :c:expr:`long long` representation of *obj*. If *obj* is not an
165-
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
165+
instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` method
166166
(if present) to convert it to a :c:type:`PyLongObject`.
167167
168168
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.
171171
Returns ``-1`` on error. Use :c:func:`PyErr_Occurred` to disambiguate.
172172
173173
.. versionchanged:: 3.8
174-
Use :meth:`__index__` if available.
174+
Use :meth:`~object.__index__` if available.
175175
176176
.. versionchanged:: 3.10
177-
This function will no longer use :meth:`__int__`.
177+
This function will no longer use :meth:`~object.__int__`.
178178
179179
180180
.. c:function:: long long PyLong_AsLongLongAndOverflow(PyObject *obj, int *overflow)
181181
182182
Return a C :c:expr:`long long` representation of *obj*. If *obj* is not an
183-
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` method
183+
instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__` method
184184
(if present) to convert it to a :c:type:`PyLongObject`.
185185
186186
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.
193193
.. versionadded:: 3.2
194194
195195
.. versionchanged:: 3.8
196-
Use :meth:`__index__` if available.
196+
Use :meth:`~object.__index__` if available.
197197
198198
.. versionchanged:: 3.10
199-
This function will no longer use :meth:`__int__`.
199+
This function will no longer use :meth:`~object.__int__`.
200200
201201
202202
.. 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.
267267
.. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *obj)
268268
269269
Return a C :c:expr:`unsigned long` representation of *obj*. If *obj* is not
270-
an instance of :c:type:`PyLongObject`, first call its :meth:`__index__`
270+
an instance of :c:type:`PyLongObject`, first call its :meth:`~object.__index__`
271271
method (if present) to convert it to a :c:type:`PyLongObject`.
272272
273273
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.
277277
disambiguate.
278278
279279
.. versionchanged:: 3.8
280-
Use :meth:`__index__` if available.
280+
Use :meth:`~object.__index__` if available.
281281
282282
.. versionchanged:: 3.10
283-
This function will no longer use :meth:`__int__`.
283+
This function will no longer use :meth:`~object.__int__`.
284284
285285
286286
.. c:function:: unsigned long long PyLong_AsUnsignedLongLongMask(PyObject *obj)
287287
288288
Return a C :c:expr:`unsigned long long` representation of *obj*. If *obj*
289289
is not an instance of :c:type:`PyLongObject`, first call its
290-
:meth:`__index__` method (if present) to convert it to a
290+
:meth:`~object.__index__` method (if present) to convert it to a
291291
:c:type:`PyLongObject`.
292292
293293
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.
297297
to disambiguate.
298298
299299
.. versionchanged:: 3.8
300-
Use :meth:`__index__` if available.
300+
Use :meth:`~object.__index__` if available.
301301
302302
.. versionchanged:: 3.10
303-
This function will no longer use :meth:`__int__`.
303+
This function will no longer use :meth:`~object.__int__`.
304304
305305
306306
.. 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)
@@ -681,8 +681,8 @@ are always available. They are listed here in alphabetical order.
681681
float, an :exc:`OverflowError` will be raised.
682682

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

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

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

710710
.. versionchanged:: 3.8
711-
Falls back to :meth:`__index__` if :meth:`__float__` is not defined.
711+
Falls back to :meth:`~object.__index__` if :meth:`~object.__float__` is not defined.
712712

713713

714714
.. index::
@@ -822,7 +822,7 @@ are always available. They are listed here in alphabetical order.
822822

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

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

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

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

934934
.. versionchanged:: 3.8
935-
Falls back to :meth:`__index__` if :meth:`__int__` is not defined.
935+
Falls back to :meth:`~object.__index__` if :meth:`~object.__int__` is not defined.
936936

937937
.. versionchanged:: 3.11
938-
The delegation to :meth:`__trunc__` is deprecated.
938+
The delegation to :meth:`~object.__trunc__` is deprecated.
939939

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

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

11441144
>>> 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)