Skip to content

Commit

Permalink
pythongh-121300: Add replace to copy.__all__ (python#121302)
Browse files Browse the repository at this point in the history
  • Loading branch information
max-muoto authored Jul 3, 2024
1 parent ca2e876 commit 7c66906
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Lib/copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import copy
x = copy.copy(y) # make a shallow copy of y
x = copy.deepcopy(y) # make a deep 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.replace(y, a=1, b=2) # new object with fields replaced, as defined by `__replace__`
For module specific errors, copy.Error is raised.
Expand Down Expand Up @@ -56,7 +57,7 @@ class Error(Exception):
pass
error = Error # backward compatibility

__all__ = ["Error", "copy", "deepcopy"]
__all__ = ["Error", "copy", "deepcopy", "replace"]

def copy(x):
"""Shallow copy operation on arbitrary Python objects.
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,10 @@ class C:
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


Expand Down

0 comments on commit 7c66906

Please sign in to comment.