[Python-ideas] Put default setstate and getstate on object for use in coöperative inheritance.

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Jun 8 01:09:30 CEST 2014


Neil Girdhar wrote:
> Have you tried implementing getstate and setstate with cooperatively 
> inherited classes?  You'll need to call super().__getstate__(), which 
> won't exist, but it really should.

The same issue exists with *any* method that you use in
a cooperative super call. You need to ensure that there is
a class at the end of the MRO with a method that terminates
the super call chain.

It's obviously infeasible to add all such possible methods
to class object. You will have to provide a *very* strong
reason why __getstate__ and __setstate__ should be singled
out for special treatment in this regard.

-- 
Greg


More information about the Python-ideas mailing list