diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-30 15:20:02 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-30 15:20:02 (GMT) |
commit | 2329eeda0cabfda89e915e9a571a229707602963 (patch) | |
tree | bf58923c33a7c8a3f6d71aa8424539a497383912 | |
parent | 03f3c2fa5f7c9b5a178f7af842411a92f5c93791 (diff) | |
download | cpython-2329eeda0cabfda89e915e9a571a229707602963.zip cpython-2329eeda0cabfda89e915e9a571a229707602963.tar.gz cpython-2329eeda0cabfda89e915e9a571a229707602963.tar.bz2 |
Issue #25718: Fixed copying object with state with boolean value is false.
-rw-r--r-- | Lib/copy.py | 4 | ||||
-rw-r--r-- | Lib/test/test_copy.py | 9 | ||||
-rw-r--r-- | Misc/NEWS | 2 |
3 files changed, 13 insertions, 2 deletions
diff --git a/Lib/copy.py b/Lib/copy.py index c227a2e..daf81a3 100644 --- a/Lib/copy.py +++ b/Lib/copy.py @@ -315,7 +315,7 @@ def _reconstruct(x, info, deep, memo=None): if n > 2: state = info[2] else: - state = {} + state = None if n > 3: listiter = info[3] else: @@ -329,7 +329,7 @@ def _reconstruct(x, info, deep, memo=None): 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 index 6b64f10..aefc433 100644 --- a/Lib/test/test_copy.py +++ b/Lib/test/test_copy.py @@ -165,6 +165,9 @@ class TestCopy(unittest.TestCase): 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 @@ class TestCopy(unittest.TestCase): 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) @@ -20,6 +20,8 @@ Core and Builtins 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. |