Skip to content

Commit dd1bbb5

Browse files
committed
gh-109961: Fix incorrect rendering of __replace__ in library/copy.rst
1 parent ea285ad commit dd1bbb5

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

Doc/library/copy.rst

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,27 +88,33 @@ pickle functions from the :mod:`copyreg` module.
8888
single: __deepcopy__() (copy protocol)
8989

9090
In order for a class to define its own copy implementation, it can define
91-
special methods :meth:`__copy__` and :meth:`__deepcopy__`. The former is called
92-
to implement the shallow copy operation; no additional arguments are passed.
93-
The latter is called to implement the deep copy operation; it is passed one
94-
argument, the ``memo`` dictionary. If the :meth:`__deepcopy__` implementation needs
95-
to make a deep copy of a component, it should call the :func:`deepcopy` function
96-
with the component as first argument and the memo dictionary as second argument.
97-
The memo dictionary should be treated as an opaque object.
91+
special methods :meth:`~object.__copy__` and :meth:`~object.__deepcopy__`.
92+
93+
.. method:: object.__copy__(self)
94+
95+
Called to implement the shallow copy operation;
96+
no additional arguments are passed.
97+
98+
.. method:: object.__deepcopy__(self, memo)
99+
100+
Called to implement the deep copy operation; it is passed one
101+
argument, the *memo* dictionary. If the ``__deepcopy__`` implementation needs
102+
to make a deep copy of a component, it should call the :func:`deepcopy` function
103+
with the component as first argument and the *memo* dictionary as second argument.
104+
The *memo* dictionary should be treated as an opaque object.
98105

99106

100107
.. index::
101108
single: __replace__() (replace protocol)
102109

103110
Function :func:`replace` is more limited than :func:`copy` and :func:`deepcopy`,
104111
and only supports named tuples created by :func:`~collections.namedtuple`,
105-
:mod:`dataclasses`, and other classes which define method :meth:`!__replace__`.
112+
:mod:`dataclasses`, and other classes which define method :meth:`~object.__replace__`.
106113

107-
.. method:: __replace__(self, /, **changes)
108-
:noindex:
114+
.. method:: object.__replace__(self, /, **changes)
109115

110-
:meth:`!__replace__` should create a new object of the same type,
111-
replacing fields with values from *changes*.
116+
This method should create a new object of the same type,
117+
replacing fields with values from *changes*.
112118

113119

114120
.. seealso::

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ Doc/library/collections.rst
4848
Doc/library/concurrent.futures.rst
4949
Doc/library/configparser.rst
5050
Doc/library/contextlib.rst
51-
Doc/library/copy.rst
5251
Doc/library/csv.rst
5352
Doc/library/datetime.rst
5453
Doc/library/dbm.rst

0 commit comments

Comments
 (0)