This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author amaury.forgeotdarc
Recipients amaury.forgeotdarc, mjuric, python-dev, rhettinger
Date 2011-04-19.20:58:09
SpamBayes Score 5.714521e-07
Marked as misclassified No
Message-id <1303246690.53.0.190220791239.issue11875@psf.upfronthosting.co.za>
In-reply-to
Content
The call to self.__class__() can break subclasses of OrderedDict for two reasons:
- The subclass constructor may have a different signature
- Attributes set by the subclass.__init__ are removed from the pickle::

import collections, pickle

class Mydict(collections.OrderedDict):
    def __init__(self, *args, name=None, **kwargs):
        super().__init__(*args, **kwargs)
        self.name = name

a = Mydict(name='foo')
b = pickle.loads(pickle.dumps(a))
print(a.name, b.name)

Previously, the 'name' would be correctly copied, now it is reset to None.
History
Date User Action Args
2011-04-19 20:58:10amaury.forgeotdarcsetrecipients: + amaury.forgeotdarc, rhettinger, python-dev, mjuric
2011-04-19 20:58:10amaury.forgeotdarcsetmessageid: <1303246690.53.0.190220791239.issue11875@psf.upfronthosting.co.za>
2011-04-19 20:58:09amaury.forgeotdarclinkissue11875 messages
2011-04-19 20:58:09amaury.forgeotdarccreate