[New-bugs-announce] [issue6827] deepcopy erroneously doesn't call __setstate__ if __getstate__ returns empty dict

Shaun Cutts report at bugs.python.org
Wed Sep 2 23:29:52 CEST 2009


New submission from Shaun Cutts <shauncutts at users.sourceforge.net>:

Line 335 of copy.py guards call to __setstate__ with

if state:
    ...

However, __getstate__ may legitimately return an empty dictionary even
if __setstate__ still needs to be called. For example,
__setstate__/__getstate__ pair may not want to "persist" default values
(as is the case for me).

The fix would be to change this line to (e.g.):

if state is not None:
    ...

----------
components: Library (Lib)
files: deepcopy_bug.py
messages: 92186
nosy: shauncutts
severity: normal
status: open
title: deepcopy erroneously doesn't call __setstate__ if __getstate__ returns empty dict
type: behavior
versions: Python 2.5
Added file: http://bugs.python.org/file14822/deepcopy_bug.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6827>
_______________________________________


More information about the New-bugs-announce mailing list