Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
cbbec1c5
Commit
cbbec1c5
authored
Nov 30, 2015
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #25718: Fixed copying object with state with boolean value is false.
parent
7279befc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
2 deletions
+13
-2
Lib/copy.py
Lib/copy.py
+2
-2
Lib/test/test_copy.py
Lib/test/test_copy.py
+9
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/copy.py
View file @
cbbec1c5
...
...
@@ -281,7 +281,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
:
...
...
@@ -295,7 +295,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__'
):
...
...
Lib/test/test_copy.py
View file @
cbbec1c5
...
...
@@ -180,6 +180,9 @@ class TestCopy(unittest.TestCase):
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 @@ class TestCopy(unittest.TestCase):
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
:
...
...
Misc/NEWS
View file @
cbbec1c5
...
...
@@ -113,6 +113,8 @@ Core and Builtins
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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment