]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-109961: Docs: Fix incorrect rendering of `__replace__` in `copy.rst` (#109968)
authorNikita Sobolev <mail@sobolevn.me>
Thu, 28 Sep 2023 11:51:33 +0000 (14:51 +0300)
committerGitHub <noreply@github.com>
Thu, 28 Sep 2023 11:51:33 +0000 (14:51 +0300)
Doc/library/copy.rst
Doc/tools/.nitignore

index cc4ca034d07a00b7b88c3430ebe1eaa4b83e66aa..811b2c51dd3d52cb14a47f3a663dafe751a8c21f 100644 (file)
@@ -88,13 +88,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.
 
 
 .. index::
@@ -102,13 +111,13 @@ The memo dictionary should be treated as an opaque object.
 
 Function :func:`replace` is more limited than :func:`copy` and :func:`deepcopy`,
 and only supports named tuples created by :func:`~collections.namedtuple`,
-:mod:`dataclasses`, and other classes which define method :meth:`!__replace__`.
+:mod:`dataclasses`, and other classes which define method :meth:`~object.__replace__`.
 
-   .. method:: __replace__(self, /, **changes)
-      :noindex:
+.. method:: object.__replace__(self, /, **changes)
+   :noindexentry:
 
-:meth:`!__replace__` should create a new object of the same type,
-replacing fields with values from *changes*.
+   This method should create a new object of the same type,
+   replacing fields with values from *changes*.
 
 
 .. seealso::
index a5fb940b150ee8eca5f0315cc4f7848caf3d7fe7..2478f305884162e14d8a8b6f2360b5a05cea2122 100644 (file)
@@ -48,7 +48,6 @@ Doc/library/collections.rst
 Doc/library/concurrent.futures.rst
 Doc/library/configparser.rst
 Doc/library/contextlib.rst
-Doc/library/copy.rst
 Doc/library/csv.rst
 Doc/library/datetime.rst
 Doc/library/dbm.rst