Content-Length: 21416 | pFad | http://github.com/python/cpython/pull/106278.patch
thub.com
From f494f505270da90debd56cb28c07ee0efc1d56e4 Mon Sep 17 00:00:00 2001
From: Yuki
Date: Fri, 30 Jun 2023 11:29:59 +0000
Subject: [PATCH 1/6] gh-101100: Fix references to ``object`` methods
``__index__``, ``__int__``, ``__float__``, ``__complex__`` are methods
of ``object``, so prepended `~object` to reference correctly.
---
Doc/c-api/complex.rst | 10 +++++-----
Doc/c-api/float.rst | 6 +++---
Doc/c-api/long.rst | 36 ++++++++++++++++++------------------
Doc/library/cmath.rst | 2 +-
Doc/library/functions.rst | 28 ++++++++++++++--------------
Doc/library/struct.rst | 4 ++--
6 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/Doc/c-api/complex.rst b/Doc/c-api/complex.rst
index 344da903da4c1a..903e9391ee90ae 100644
--- a/Doc/c-api/complex.rst
+++ b/Doc/c-api/complex.rst
@@ -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 `~object.__complex__` is not defined then it falls back to
+ :meth:`~object.__float__`. If `~object.__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.
diff --git a/Doc/c-api/float.rst b/Doc/c-api/float.rst
index 0118bea4e720f8..4fe6912746a384 100644
--- a/Doc/c-api/float.rst
+++ b/Doc/c-api/float.rst
@@ -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 `~object.__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)
diff --git a/Doc/c-api/long.rst b/Doc/c-api/long.rst
index 5c1d026a330ae7..fe379ffe912391 100644
--- a/Doc/c-api/long.rst
+++ b/Doc/c-api/long.rst
@@ -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)
diff --git a/Doc/library/cmath.rst b/Doc/library/cmath.rst
index b17d58e1cc0ce1..fdac51d9603ceb 100644
--- a/Doc/library/cmath.rst
+++ b/Doc/library/cmath.rst
@@ -9,7 +9,7 @@
This module provides access to mathematical functions for complex numbers. The
functions in this module accept integers, floating-point numbers or complex
numbers as arguments. They will also accept any Python object that has either a
-:meth:`__complex__` or a :meth:`__float__` method: these methods are used to
+:meth:`~object.__complex__` or a :meth:`~object.__float__` method: these methods are used to
convert the object to a complex or floating-point number, respectively, and
the function is then applied to the result of the conversion.
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 3d2bb8efc95d8e..8bf3c86ef52c6e 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -122,7 +122,7 @@ are always available. They are listed here in alphabetical order.
Convert an integer number to a binary string prefixed with "0b". The result
is a valid Python expression. If *x* is not a Python :class:`int` object, it
- has to define an :meth:`__index__` method that returns an integer. Some
+ has to define an :meth:`~object.__index__` method that returns an integer. Some
examples:
>>> bin(3)
@@ -383,9 +383,9 @@ are always available. They are listed here in alphabetical order.
``0j``.
For a general Python object ``x``, ``complex(x)`` delegates to
- ``x.__complex__()``. If ``__complex__()`` is not defined then it falls back
- to :meth:`__float__`. If ``__float__()`` is not defined then it falls back
- to :meth:`__index__`.
+ ``x.__complex__()``. If :meth:`~object.__complex__` is not defined then it falls back
+ to :meth:`~object.__float__`. If :meth:`~object.__float__` is not defined then it falls back
+ to :meth:`~object.__index__`.
.. note::
@@ -400,8 +400,8 @@ are always available. They are listed here in alphabetical order.
Grouping digits with underscores as in code literals is allowed.
.. versionchanged:: 3.8
- Falls back to :meth:`__index__` if :meth:`__complex__` and
- :meth:`__float__` are not defined.
+ Falls back to :meth:`~object.__index__` if :meth:`~object.__complex__` and
+ :meth:`~object.__float__` are not defined.
.. function:: delattr(object, name)
@@ -681,8 +681,8 @@ are always available. They are listed here in alphabetical order.
float, an :exc:`OverflowError` will be raised.
For a general Python object ``x``, ``float(x)`` delegates to
- ``x.__float__()``. If ``__float__()`` is not defined then it falls back
- to :meth:`__index__`.
+ ``x.__float__()``. If :meth:`~object.__float__` is not defined then it falls back
+ to :meth:`~object.__index__`.
If no argument is given, ``0.0`` is returned.
@@ -708,7 +708,7 @@ are always available. They are listed here in alphabetical order.
*x* is now a positional-only parameter.
.. versionchanged:: 3.8
- Falls back to :meth:`__index__` if :meth:`__float__` is not defined.
+ Falls back to :meth:`~object.__index__` if :meth:`~object.__float__` is not defined.
.. index::
@@ -822,7 +822,7 @@ are always available. They are listed here in alphabetical order.
Convert an integer number to a lowercase hexadecimal string prefixed with
"0x". If *x* is not a Python :class:`int` object, it has to define an
- :meth:`__index__` method that returns an integer. Some examples:
+ :meth:`~object.__index__` method that returns an integer. Some examples:
>>> hex(255)
'0xff'
@@ -893,8 +893,8 @@ are always available. They are listed here in alphabetical order.
int(x, base=10)
Return an integer object constructed from a number or string *x*, or return
- ``0`` if no arguments are given. If *x* defines :meth:`__int__`,
- ``int(x)`` returns ``x.__int__()``. If *x* defines :meth:`__index__`,
+ ``0`` if no arguments are given. If *x* defines :meth:`~object.__int__`,
+ ``int(x)`` returns ``x.__int__()``. If *x* defines :meth:`~object.__index__`,
it returns ``x.__index__()``. If *x* defines :meth:`__trunc__`,
it returns ``x.__trunc__()``.
For floating point numbers, this truncates towards zero.
@@ -932,7 +932,7 @@ are always available. They are listed here in alphabetical order.
*x* is now a positional-only parameter.
.. versionchanged:: 3.8
- Falls back to :meth:`__index__` if :meth:`__int__` is not defined.
+ Falls back to :meth:`~object.__index__` if :meth:`~object.__int__` is not defined.
.. versionchanged:: 3.11
The delegation to :meth:`__trunc__` is deprecated.
@@ -1138,7 +1138,7 @@ are always available. They are listed here in alphabetical order.
Convert an integer number to an octal string prefixed with "0o". The result
is a valid Python expression. If *x* is not a Python :class:`int` object, it
- has to define an :meth:`__index__` method that returns an integer. For
+ has to define an :meth:`~object.__index__` method that returns an integer. For
example:
>>> oct(8)
diff --git a/Doc/library/struct.rst b/Doc/library/struct.rst
index 78fd6e397ae635..6d2739b4557fbf 100644
--- a/Doc/library/struct.rst
+++ b/Doc/library/struct.rst
@@ -266,11 +266,11 @@ Notes:
(2)
When attempting to pack a non-integer using any of the integer conversion
- codes, if the non-integer has a :meth:`__index__` method then that method is
+ codes, if the non-integer has a :meth:`~object.__index__` method then that method is
called to convert the argument to an integer before packing.
.. versionchanged:: 3.2
- Added use of the :meth:`__index__` method for non-integers.
+ Added use of the :meth:`~object.__index__` method for non-integers.
(3)
The ``'n'`` and ``'N'`` conversion codes are only available for the native
From 2abc1c9b92bd58ab185c887e2b8a3b9fc1482c07 Mon Sep 17 00:00:00 2001
From: Yuki
Date: Fri, 30 Jun 2023 11:38:02 +0000
Subject: [PATCH 2/6] fixup
---
Doc/c-api/complex.rst | 4 ++--
Doc/c-api/float.rst | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Doc/c-api/complex.rst b/Doc/c-api/complex.rst
index 903e9391ee90ae..8e1c833ecfe38d 100644
--- a/Doc/c-api/complex.rst
+++ b/Doc/c-api/complex.rst
@@ -129,8 +129,8 @@ Complex Numbers as Python Objects
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 `~object.__complex__` is not defined then it falls back to
- :meth:`~object.__float__`. If `~object.__float__` is not defined then it falls back
+ number object. If :meth:`~object.__complex__` is not defined then it falls back to
+ :meth:`~object.__float__`. If :meth:`~object.__float__` is not defined then it falls back
to :meth:`~object.__index__`. Upon failure, this method returns ``-1.0`` as a real
value.
diff --git a/Doc/c-api/float.rst b/Doc/c-api/float.rst
index 4fe6912746a384..ae17c6beb0a785 100644
--- a/Doc/c-api/float.rst
+++ b/Doc/c-api/float.rst
@@ -47,7 +47,7 @@ Floating Point Objects
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:`~object.__float__`
method, this method will first be called to convert *pyfloat* into a float.
- If `~object.__float__` is not defined then it falls back to :meth:`~object.__index__`.
+ If :meth:`~object.__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.
From 32e039de4afed84801a6549bc089448ea56db3eb Mon Sep 17 00:00:00 2001
From: Yuki
Date: Fri, 30 Jun 2023 13:48:12 +0000
Subject: [PATCH 3/6] Fix references to ``__trunc__``
---
Doc/library/functions.rst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 8bf3c86ef52c6e..48c0f39b96a4e9 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -895,7 +895,7 @@ are always available. They are listed here in alphabetical order.
Return an integer object constructed from a number or string *x*, or return
``0`` if no arguments are given. If *x* defines :meth:`~object.__int__`,
``int(x)`` returns ``x.__int__()``. If *x* defines :meth:`~object.__index__`,
- it returns ``x.__index__()``. If *x* defines :meth:`__trunc__`,
+ it returns ``x.__index__()``. If *x* defines :meth:`~object.__trunc__`,
it returns ``x.__trunc__()``.
For floating point numbers, this truncates towards zero.
@@ -935,7 +935,7 @@ are always available. They are listed here in alphabetical order.
Falls back to :meth:`~object.__index__` if :meth:`~object.__int__` is not defined.
.. versionchanged:: 3.11
- The delegation to :meth:`__trunc__` is deprecated.
+ The delegation to :meth:`~object.__trunc__` is deprecated.
.. versionchanged:: 3.11
:class:`int` string inputs and string representations can be limited to
From 324e4aec0847d0e9431131544309015cd7c18d5e Mon Sep 17 00:00:00 2001
From: F3eQnxN3RriK
Date: Fri, 30 Jun 2023 23:13:17 +0900
Subject: [PATCH 4/6] Update Doc/c-api/complex.rst
Co-authored-by: Alex Waygood
---
Doc/c-api/complex.rst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Doc/c-api/complex.rst b/Doc/c-api/complex.rst
index 8e1c833ecfe38d..cb8b270fcbab6e 100644
--- a/Doc/c-api/complex.rst
+++ b/Doc/c-api/complex.rst
@@ -129,8 +129,8 @@ Complex Numbers as Python Objects
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 :meth:`~object.__complex__` is not defined then it falls back to
- :meth:`~object.__float__`. If :meth:`~object.__float__` is not defined then it falls back
+ 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.
From 77e4d9a662bc0bbfe23f74d7018c9a5c0dfab5b8 Mon Sep 17 00:00:00 2001
From: F3eQnxN3RriK
Date: Fri, 30 Jun 2023 23:13:57 +0900
Subject: [PATCH 5/6] Update Doc/c-api/float.rst
Co-authored-by: Alex Waygood
---
Doc/c-api/float.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Doc/c-api/float.rst b/Doc/c-api/float.rst
index ae17c6beb0a785..fd0be1108c6300 100644
--- a/Doc/c-api/float.rst
+++ b/Doc/c-api/float.rst
@@ -47,7 +47,7 @@ Floating Point Objects
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:`~object.__float__`
method, this method will first be called to convert *pyfloat* into a float.
- If :meth:`~object.__float__` is not defined then it falls back to :meth:`~object.__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.
From a184c6261eebbd7af44a3aa11335a9397124bb23 Mon Sep 17 00:00:00 2001
From: F3eQnxN3RriK
Date: Fri, 30 Jun 2023 23:14:40 +0900
Subject: [PATCH 6/6] Update Doc/library/functions.rst
Co-authored-by: Alex Waygood
---
Doc/library/functions.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 48c0f39b96a4e9..9b9731e9189853 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -384,7 +384,7 @@ are always available. They are listed here in alphabetical order.
For a general Python object ``x``, ``complex(x)`` delegates to
``x.__complex__()``. If :meth:`~object.__complex__` is not defined then it falls back
- to :meth:`~object.__float__`. If :meth:`~object.__float__` 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__`.
.. note::
--- a PPN by Garber Painting Akron. With Image Size Reduction included!Fetched URL: http://github.com/python/cpython/pull/106278.patch
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy