Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc9215f

Browse files
committed
Issue #20791: copy.copy() now doesn't make a copy when the input is a bytes object. Initial patch by Peter Otten.
1 parent 85736a7 commit dc9215f

3 files changed

Lines changed: 5 additions & 1 deletion

File tree

Lib/copy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def copy(x):
110110
def _copy_immutable(x):
111111
return x
112112
for t in (type(None), int, float, bool, str, tuple,
113-
frozenset, type, range,
113+
bytes, frozenset, type, range,
114114
types.BuiltinFunctionType, type(Ellipsis),
115115
types.FunctionType, weakref.ref):
116116
d[t] = _copy_immutable

Lib/test/test_copy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class WithMetaclass(metaclass=abc.ABCMeta):
9898
pass
9999
tests = [None, 42, 2**100, 3.14, True, False, 1j,
100100
"hello", "hello\u1234", f.__code__,
101+
b"world", bytes(range(256)),
101102
NewStyle, range(10), Classic, max, WithMetaclass]
102103
for x in tests:
103104
self.assertIs(copy.copy(x), x)

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ Core and Builtins
1414
Library
1515
-------
1616

17+
- Issue #20791: copy.copy() now doesn't make a copy when the input is
18+
a bytes object. Initial patch by Peter Otten.
19+
1720
- Issue #19748: On AIX, time.mktime() now raises an OverflowError for year
1821
outsize range [1902; 2037].
1922

0 commit comments

Comments
 (0)