cpython (3.4): Issue #25718: Fixed copying object with state with boolean value is false.
https://hg.python.org/cpython/rev/095d21df9374 changeset: 99392:095d21df9374 branch: 3.4 parent: 99382:d47e5b162072 user: Serhiy Storchaka <storchaka@gmail.com> date: Mon Nov 30 17:20:02 2015 +0200 summary: Issue #25718: Fixed copying object with state with boolean value is false. files: Lib/copy.py | 4 ++-- Lib/test/test_copy.py | 9 +++++++++ Misc/NEWS | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Lib/copy.py b/Lib/copy.py --- a/Lib/copy.py +++ b/Lib/copy.py @@ -281,7 +281,7 @@ if n > 2: state = info[2] else: - state = {} + state = None if n > 3: listiter = info[3] else: @@ -295,7 +295,7 @@ y = callable(*args) memo[id(x)] = y - if state: + if state is not None: if deep: state = deepcopy(state, memo) if hasattr(y, '__setstate__'): 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 @@ -180,6 +180,9 @@ return self.foo == other.foo x = C(42) self.assertEqual(copy.copy(x), x) + # State with boolean value is false (issue #25718) + x = C(0.0) + self.assertEqual(copy.copy(x), x) # The deepcopy() method @@ -448,6 +451,12 @@ self.assertEqual(y, x) self.assertIsNot(y, x) self.assertIsNot(y.foo, x.foo) + # State with boolean value is false (issue #25718) + x = C([]) + y = copy.deepcopy(x) + self.assertEqual(y, x) + self.assertIsNot(y, x) + self.assertIsNot(y.foo, x.foo) def test_deepcopy_reflexive_inst(self): class C: diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -113,6 +113,8 @@ Library ------- +- Issue #25718: Fixed copying object with state with boolean value is false. + - Issue #10131: Fixed deep copying of minidom documents. Based on patch by Marian Ganisin. -- Repository URL: https://hg.python.org/cpython
participants (1)
-
serhiy.storchaka