]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-108751: Add copy.replace() function (GH-108752)
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 6 Sep 2023 20:55:42 +0000 (23:55 +0300)
committerGitHub <noreply@github.com>
Wed, 6 Sep 2023 20:55:42 +0000 (23:55 +0300)
commit6f3c138dfa868b32d3288898923bbfa388f2fa5d
tree98098db4d0d2f256f2a17d515c1750a28424166c
parent9f0c0a46f00d687e921990ee83894b2f4ce8a6e7
gh-108751: Add copy.replace() function (GH-108752)

It creates a modified copy of an object by calling the object's
__replace__() method.

It is a generalization of dataclasses.replace(), named tuple's _replace()
method and replace() methods in various classes, and supports all these
stdlib classes.
19 files changed:
Doc/library/collections.rst
Doc/library/copy.rst
Doc/library/dataclasses.rst
Doc/library/datetime.rst
Doc/library/inspect.rst
Doc/library/types.rst
Doc/whatsnew/3.13.rst
Lib/_pydatetime.py
Lib/collections/__init__.py
Lib/copy.py
Lib/dataclasses.py
Lib/inspect.py
Lib/test/datetimetester.py
Lib/test/test_code.py
Lib/test/test_copy.py
Lib/test/test_inspect.py
Misc/NEWS.d/next/Library/2023-09-01-13-14-08.gh-issue-108751.2itqwe.rst [new file with mode: 0644]
Modules/_datetimemodule.c
Objects/codeobject.c