mirror of
https://github.com/python/cpython.git
synced 2025-10-07 23:51:16 +00:00
gh-121300: Add replace
to copy.__all__
(#121302)
This commit is contained in:
parent
ca2e876500
commit
7c66906802
2 changed files with 8 additions and 3 deletions
|
@ -6,6 +6,7 @@ Interface summary:
|
||||||
|
|
||||||
x = copy.copy(y) # make a shallow copy of y
|
x = copy.copy(y) # make a shallow copy of y
|
||||||
x = copy.deepcopy(y) # make a deep copy of y
|
x = copy.deepcopy(y) # make a deep copy of y
|
||||||
|
x = copy.replace(y, a=1, b=2) # new object with fields replaced, as defined by `__replace__`
|
||||||
|
|
||||||
For module specific errors, copy.Error is raised.
|
For module specific errors, copy.Error is raised.
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ class Error(Exception):
|
||||||
pass
|
pass
|
||||||
error = Error # backward compatibility
|
error = Error # backward compatibility
|
||||||
|
|
||||||
__all__ = ["Error", "copy", "deepcopy"]
|
__all__ = ["Error", "copy", "deepcopy", "replace"]
|
||||||
|
|
||||||
def copy(x):
|
def copy(x):
|
||||||
"""Shallow copy operation on arbitrary Python objects.
|
"""Shallow copy operation on arbitrary Python objects.
|
||||||
|
|
|
@ -972,6 +972,10 @@ class TestReplace(unittest.TestCase):
|
||||||
copy.replace(c, x=1, error=2)
|
copy.replace(c, x=1, error=2)
|
||||||
|
|
||||||
|
|
||||||
|
class MiscTestCase(unittest.TestCase):
|
||||||
|
def test__all__(self):
|
||||||
|
support.check__all__(self, copy, not_exported={"dispatch_table", "error"})
|
||||||
|
|
||||||
def global_foo(x, y): return x+y
|
def global_foo(x, y): return x+y
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue