[Python-checkins] cpython: Issue #20791: copy.copy() now doesn't make a copy when the input is a bytes

antoine.pitrou python-checkins at python.org
Thu Feb 27 22:16:05 CET 2014


http://hg.python.org/cpython/rev/c2523bca50d7
changeset:   89409:c2523bca50d7
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Thu Feb 27 22:14:31 2014 +0100
summary:
  Issue #20791: copy.copy() now doesn't make a copy when the input is a bytes object.  Initial patch by Peter Otten.

files:
  Lib/copy.py           |  2 +-
  Lib/test/test_copy.py |  1 +
  Misc/NEWS             |  3 +++
  3 files changed, 5 insertions(+), 1 deletions(-)


diff --git a/Lib/copy.py b/Lib/copy.py
--- a/Lib/copy.py
+++ b/Lib/copy.py
@@ -110,7 +110,7 @@
 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
--- a/Lib/test/test_copy.py
+++ b/Lib/test/test_copy.py
@@ -98,6 +98,7 @@
             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
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -14,6 +14,9 @@
 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].
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list