From: Antoine Pitrou Date: Thu, 27 Feb 2014 21:14:31 +0000 (+0100) Subject: Issue #20791: copy.copy() now doesn't make a copy when the input is a bytes object... X-Git-Tag: v3.4.1rc1~233^2~186 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dc9215f8828b23ed6c294f8e64342a55dcdf1e4c;p=thirdparty%2FPython%2Fcpython.git Issue #20791: copy.copy() now doesn't make a copy when the input is a bytes object. Initial patch by Peter Otten. --- diff --git a/Lib/copy.py b/Lib/copy.py index d26bcdbff6ae..bb8840ed549a 100644 --- a/Lib/copy.py +++ b/Lib/copy.py @@ -110,7 +110,7 @@ _copy_dispatch = d = {} def _copy_immutable(x): return x for t in (type(None), int, float, bool, str, tuple, - frozenset, type, range, + bytes, frozenset, type, range, types.BuiltinFunctionType, type(Ellipsis), types.FunctionType, weakref.ref): d[t] = _copy_immutable diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py index cde0baecad62..eb8d18cf0b12 100644 --- a/Lib/test/test_copy.py +++ b/Lib/test/test_copy.py @@ -98,6 +98,7 @@ class TestCopy(unittest.TestCase): pass tests = [None, 42, 2**100, 3.14, True, False, 1j, "hello", "hello\u1234", f.__code__, + b"world", bytes(range(256)), NewStyle, range(10), Classic, max, WithMetaclass] for x in tests: self.assertIs(copy.copy(x), x) diff --git a/Misc/NEWS b/Misc/NEWS index d58d17bff034..77b969cecfb1 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -14,6 +14,9 @@ Core and Builtins Library ------- +- Issue #20791: copy.copy() now doesn't make a copy when the input is + a bytes object. Initial patch by Peter Otten. + - Issue #19748: On AIX, time.mktime() now raises an OverflowError for year outsize range [1902; 2037].