summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-01-28 21:43:35 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2016-01-28 21:43:35 +0200
commit4827b8b880eb2c7f41ba6c969993c851ca0b8435 (patch)
treeb85b901160fdef8c89887db3fd9b46da4267bb2d
parent970044ad1123e97926b3c817711598a838c66ecc (diff)
downloadcpython-4827b8b880eb2c7f41ba6c969993c851ca0b8435.tar.gz
Issue #26202: copy.deepcopy() now correctly copies range() objects with
non-atomic attributes.
-rw-r--r--Lib/copy.py1
-rw-r--r--Lib/test/test_copy.py13
-rw-r--r--Misc/NEWS3
3 files changed, 15 insertions, 2 deletions
diff --git a/Lib/copy.py b/Lib/copy.py
index 493c487d8a..972b94ab49 100644
--- a/Lib/copy.py
+++ b/Lib/copy.py
@@ -207,7 +207,6 @@ try:
except AttributeError:
pass
d[type] = _deepcopy_atomic
-d[range] = _deepcopy_atomic
d[types.BuiltinFunctionType] = _deepcopy_atomic
d[types.FunctionType] = _deepcopy_atomic
d[weakref.ref] = _deepcopy_atomic
diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py
index 4107e8afd6..7912c7cd69 100644
--- a/Lib/test/test_copy.py
+++ b/Lib/test/test_copy.py
@@ -314,7 +314,7 @@ class TestCopy(unittest.TestCase):
pass
tests = [None, 42, 2**100, 3.14, True, False, 1j,
"hello", "hello\u1234", f.__code__,
- NewStyle, range(10), Classic, max]
+ NewStyle, Classic, max]
for x in tests:
self.assertIs(copy.deepcopy(x), x)
@@ -536,6 +536,17 @@ class TestCopy(unittest.TestCase):
self.assertIsNot(y, x)
self.assertIs(y.foo, y)
+ def test_deepcopy_range(self):
+ class I(int):
+ pass
+ x = range(I(10))
+ y = copy.deepcopy(x)
+ self.assertIsNot(y, x)
+ self.assertEqual(y, x)
+ self.assertIsNot(y.stop, x.stop)
+ self.assertEqual(y.stop, x.stop)
+ self.assertIsInstance(y.stop, I)
+
# _reconstruct()
def test_reconstruct_string(self):
diff --git a/Misc/NEWS b/Misc/NEWS
index cd693fc93c..cbfae9bdf3 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -66,6 +66,9 @@ Core and Builtins
Library
-------
+- Issue #26202: copy.deepcopy() now correctly copies range() objects with
+ non-atomic attributes.
+
- Issue #19883: Fixed possible integer overflows in zipimport.
- Issue #26227: On Windows, getnameinfo(), gethostbyaddr() and