[Python-checkins] cpython (merge 3.5 -> default): Issue #26202: copy.deepcopy() now correctly copies range() objects with
serhiy.storchaka
python-checkins at python.org
Thu Jan 28 14:44:41 EST 2016
https://hg.python.org/cpython/rev/d5d0b62c2830
changeset: 100106:d5d0b62c2830
parent: 100103:f4631dc56ecf
parent: 100105:5772eae17a82
user: Serhiy Storchaka <storchaka at gmail.com>
date: Thu Jan 28 21:43:51 2016 +0200
summary:
Issue #26202: copy.deepcopy() now correctly copies range() objects with
non-atomic attributes.
files:
Lib/copy.py | 1 -
Lib/test/test_copy.py | 13 ++++++++++++-
Misc/NEWS | 3 +++
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/Lib/copy.py b/Lib/copy.py
--- a/Lib/copy.py
+++ b/Lib/copy.py
@@ -207,7 +207,6 @@
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
--- a/Lib/test/test_copy.py
+++ b/Lib/test/test_copy.py
@@ -314,7 +314,7 @@
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 @@
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
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -159,6 +159,9 @@
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
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list