https://hg.python.org/cpython/rev/3d39e1e2dcb3 changeset: 99393:3d39e1e2dcb3 branch: 2.7 parent: 99390:436e58ae3bab user: Serhiy Storchaka <storchaka at 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 @@ -315,7 +315,7 @@ if n > 2: state = info[2] else: - state = {} + state = None if n > 3: listiter = info[3] else: @@ -329,7 +329,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 @@ -165,6 +165,9 @@ return cmp(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 @@ -395,6 +398,12 @@ x = C([42]) y = copy.deepcopy(x) 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.assertTrue(y is not x) self.assertTrue(y.foo is not x.foo) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -20,6 +20,8 @@ Library ------- +- Issue #25718: Fixed copying object with state with boolean value is false. + - Issue #25742: :func:`locale.setlocale` now accepts a Unicode string for its second parameter. -- Repository URL: https://hg.python.org/cpython
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4