From ba7d0001cb133fcf2f7aa73f7af5879d454eba65 Mon Sep 17 00:00:00 2001 From: Mitar Date: Mon, 14 Aug 2017 00:52:22 -0700 Subject: [PATCH 1/3] Make sure copy and deepcopy are returning same class. This should hold on Python 3.3 and newer (it does not hold on 3.2 and 2.7). --- src/test_typing.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test_typing.py b/src/test_typing.py index fd2d93c3..0686593c 100644 --- a/src/test_typing.py +++ b/src/test_typing.py @@ -1069,6 +1069,9 @@ class Node(Generic[T]): ... for t in things + [Any]: self.assertEqual(t, copy(t)) self.assertEqual(t, deepcopy(t)) + if sys.version_info >= (3, 3): + self.assertTrue(t is copy(t)) + self.assertTrue(t is deepcopy(t)) def test_weakref_all(self): T = TypeVar('T') From acf00b273f3cba76fb260ea0ee1801f933ef1f45 Mon Sep 17 00:00:00 2001 From: Mitar Date: Tue, 15 Aug 2017 02:46:03 -0700 Subject: [PATCH 2/3] Added comment. --- src/test_typing.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test_typing.py b/src/test_typing.py index 0686593c..4b6461a9 100644 --- a/src/test_typing.py +++ b/src/test_typing.py @@ -1070,6 +1070,10 @@ class Node(Generic[T]): ... self.assertEqual(t, copy(t)) self.assertEqual(t, deepcopy(t)) if sys.version_info >= (3, 3): + # From copy module documentation: + # It does “copy” functions and classes (shallow and deeply), by returning + # the original object unchanged; this is compatible with the way these + # are treated by the pickle module. self.assertTrue(t is copy(t)) self.assertTrue(t is deepcopy(t)) From 1130457c7d8bb26befca082e4e6dc51eef983201 Mon Sep 17 00:00:00 2001 From: Mitar Date: Tue, 15 Aug 2017 02:57:19 -0700 Subject: [PATCH 3/3] ASCII text only. --- src/test_typing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test_typing.py b/src/test_typing.py index 4b6461a9..a351be1d 100644 --- a/src/test_typing.py +++ b/src/test_typing.py @@ -1071,7 +1071,7 @@ class Node(Generic[T]): ... self.assertEqual(t, deepcopy(t)) if sys.version_info >= (3, 3): # From copy module documentation: - # It does “copy” functions and classes (shallow and deeply), by returning + # It does "copy" functions and classes (shallow and deeply), by returning # the original object unchanged; this is compatible with the way these # are treated by the pickle module. self.assertTrue(t is copy(t))