Skip to content

Commit d231cdb

Browse files
committed
copy: use _copy_atomic_types instead; add tests
1 parent 6727967 commit d231cdb

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Lib/copy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ def copy(x):
101101

102102

103103
_copy_atomic_types = frozenset({types.NoneType, int, float, bool, complex, str, tuple,
104-
bytes, frozenset, type, range, slice, property,
104+
bytes, frozenset, frozendict, type, range, slice, property,
105105
types.BuiltinFunctionType, types.EllipsisType,
106106
types.NotImplementedType, types.FunctionType, types.CodeType,
107107
weakref.ref, super})
108-
_copy_builtin_containers = frozenset({list, dict, frozendict, set, bytearray})
108+
_copy_builtin_containers = frozenset({list, dict, set, bytearray})
109109

110110
def deepcopy(x, memo=None):
111111
"""Deep copy operation on arbitrary Python objects.

Lib/test/test_copy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ def test_copy_frozenset(self):
161161
x = frozenset()
162162
self.assertIs(copy.copy(x), x)
163163

164+
def test_copy_frozendict(self):
165+
x = frozendict(x=1, y=2)
166+
self.assertIs(copy.copy(x), x)
167+
x = frozendict()
168+
self.assertIs(copy.copy(x), x)
169+
164170
def test_copy_bytearray(self):
165171
x = bytearray(b'abc')
166172
y = copy.copy(x)

0 commit comments

Comments
 (0)