Commit b807577d authored by Antoine Pitrou's avatar Antoine Pitrou

Issue #20791: copy.copy() now doesn't make a copy when the input is a bytes...

Issue #20791: copy.copy() now doesn't make a copy when the input is a bytes object.  Initial patch by Peter Otten.
parent 3673670b
...@@ -110,7 +110,7 @@ _copy_dispatch = d = {} ...@@ -110,7 +110,7 @@ _copy_dispatch = d = {}
def _copy_immutable(x): def _copy_immutable(x):
return x return x
for t in (type(None), int, float, bool, str, tuple, for t in (type(None), int, float, bool, str, tuple,
frozenset, type, range, bytes, frozenset, type, range,
types.BuiltinFunctionType, type(Ellipsis), types.BuiltinFunctionType, type(Ellipsis),
types.FunctionType, weakref.ref): types.FunctionType, weakref.ref):
d[t] = _copy_immutable d[t] = _copy_immutable
......
...@@ -98,6 +98,7 @@ class TestCopy(unittest.TestCase): ...@@ -98,6 +98,7 @@ class TestCopy(unittest.TestCase):
pass pass
tests = [None, 42, 2**100, 3.14, True, False, 1j, tests = [None, 42, 2**100, 3.14, True, False, 1j,
"hello", "hello\u1234", f.__code__, "hello", "hello\u1234", f.__code__,
b"world", bytes(range(256)),
NewStyle, range(10), Classic, max, WithMetaclass] NewStyle, range(10), Classic, max, WithMetaclass]
for x in tests: for x in tests:
self.assertIs(copy.copy(x), x) self.assertIs(copy.copy(x), x)
......
...@@ -26,6 +26,9 @@ Core and Builtins ...@@ -26,6 +26,9 @@ Core and Builtins
Library Library
------- -------
- Issue #20791: copy.copy() now doesn't make a copy when the input is
a bytes object. Initial patch by Peter Otten.
- Issue #20621: Fixes a zipimport bug introduced in 3.3.4 that could cause - Issue #20621: Fixes a zipimport bug introduced in 3.3.4 that could cause
spurious crashes or SystemErrors when importing modules or packages from a spurious crashes or SystemErrors when importing modules or packages from a
zip file. The change causing the problem was reverted. zip file. The change causing the problem was reverted.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment