[3.12] gh-109961: Docs: Fix incorrect rendering of __replace__ in copy.rst (GH-109968) (#130909)

(cherry picked from commit 0baf72696e)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
Hugo van Kemenade 2025-03-17 14:58:14 +02:00 committed by GitHub
parent 6e7432f130
commit 3983fcad95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 8 deletions

View file

@ -80,13 +80,22 @@ pickle functions from the :mod:`copyreg` module.
single: __deepcopy__() (copy protocol)
In order for a class to define its own copy implementation, it can define
special methods :meth:`__copy__` and :meth:`__deepcopy__`. The former is called
to implement the shallow copy operation; no additional arguments are passed.
The latter is called to implement the deep copy operation; it is passed one
argument, the ``memo`` dictionary. If the :meth:`__deepcopy__` implementation needs
to make a deep copy of a component, it should call the :func:`deepcopy` function
with the component as first argument and the memo dictionary as second argument.
The memo dictionary should be treated as an opaque object.
special methods :meth:`~object.__copy__` and :meth:`~object.__deepcopy__`.
.. method:: object.__copy__(self)
:noindexentry:
Called to implement the shallow copy operation;
no additional arguments are passed.
.. method:: object.__deepcopy__(self, memo)
:noindexentry:
Called to implement the deep copy operation; it is passed one
argument, the *memo* dictionary. If the ``__deepcopy__`` implementation needs
to make a deep copy of a component, it should call the :func:`deepcopy` function
with the component as first argument and the *memo* dictionary as second argument.
The *memo* dictionary should be treated as an opaque object.
.. seealso::

View file

@ -21,7 +21,6 @@ Doc/library/asyncio-policy.rst
Doc/library/audioop.rst
Doc/library/cgi.rst
Doc/library/chunk.rst
Doc/library/copy.rst
Doc/library/decimal.rst
Doc/library/email.charset.rst
Doc/library/email.compat32-message.rst