On Tue, Jan 1, 2013 at 7:09 AM, Georg Brandl <georg@python.org> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/01/2013 01:28 AM, Eli Bendersky wrote:
> In the pickle docs of 3.3, section 12.4.1 says:
>
> "instances of such classes whose __dict__ or __setstate__() is picklable"
>
> Does it actually mean __setstate__ or __getstate__ ?

ISTM __setstate__ is correct, since that's the method that has to be
looked up at unpickling time.  (__getstate__ is called at pickling time.)

Yes, __getstate__ is called at pickling time, which is precisely why it should replace __setstate__ in the quoted statement, IMHO. Note that the doc of __getstate__ says:

"Classes can further influence how their instances are pickled; if the class defines the method __getstate__(), it is called and the returned object is pickled as the contents for the instance, instead of the contents of the instance’s dictionary. If the __getstate__() method is absent, the instance’s __dict__ is pickled as usual."

Which further suggest that __getstate__ and __dict__ are, in a sense, interchangeable.

Eli