]> granicus.if.org Git - python/commitdiff
Issue #20791: copy.copy() now doesn't make a copy when the input is a bytes object...
authorAntoine Pitrou <solipsis@pitrou.net>
Thu, 27 Feb 2014 21:14:31 +0000 (22:14 +0100)
committerAntoine Pitrou <solipsis@pitrou.net>
Thu, 27 Feb 2014 21:14:31 +0000 (22:14 +0100)
Lib/copy.py
Lib/test/test_copy.py
Misc/NEWS

index d26bcdbff6ae5e0938a3befcdcc75ffac5ac5b26..bb8840ed549a5975a2e03b57b9f652e0608beb66 100644 (file)
@@ -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
index cde0baecad6234136728b2be4c8091b3dbec5ac9..eb8d18cf0b1217490af804bb7a68b86055e89546 100644 (file)
@@ -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)
index d58d17bff0345c52e0697e62b180c4034ccc26cf..77b969cecfb13a09d4a810cab86bf0bce9654a55 100644 (file)
--- 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].