Pickle question

G

Gonçalo Rodrigues

Hi,

Can I force the pickling/unpickling mechanism to call the class
constructor? I thought __getinitargs__ would do the job, but the
following shows it does not.
def __init__(self, **kwargs):
super(Test, self).__init__(**kwargs)
self.__dict__.update(kwargs)
def __getinitargs__(self):
print "Calling __getinitargs__."
return ()
def __getattr__(self, attrib):
print "Getting %s." % attrib
raise AttributeError

Getting __getstate__.
Getting __slots__.
I thought unpickling with __getinitargs__ present would go as:

1. Call class constructor with args read from pickle and return inst.
2. Update inst by either calling __setstate__ (if there is) or just
update inst.__dict__.

What am I missing?

With my best regards,
G. Rodrigues
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top