Message134099
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. |
|
Date |
User |
Action |
Args |
2011-04-19 20:58:10 | amaury.forgeotdarc | set | recipients:
+ amaury.forgeotdarc, rhettinger, python-dev, mjuric |
2011-04-19 20:58:10 | amaury.forgeotdarc | set | messageid: <1303246690.53.0.190220791239.issue11875@psf.upfronthosting.co.za> |
2011-04-19 20:58:09 | amaury.forgeotdarc | link | issue11875 messages |
2011-04-19 20:58:09 | amaury.forgeotdarc | create | |
|