Feature or enhancement
As was noted in #125714 (comment), the super object is not pickleable. For example:
import pickle
class X: pass
s = super(X, X())
pickle.dumps(s)
Produces a traceback:
Traceback (most recent call last):
File "<python-input-0>", line 4, in <module>
pickle.dumps(s)
~~~~~~~~~~~~^^^
_pickle.PicklingError: first argument to __newobj__() must be <class 'super'>, not <class '__main__.X'>
when serializing super object
This is because the special methods like __reduce_ex__() are looked up in an instance and translated to a lookup in the underlying object.
>>> super(X, X()).__reduce_ex__(5)
(<function __newobj__ at 0x7fd9e8a0ad50>, (<class '__main__.X'>,), None, None, None)
This cannot be solved by implementing the __reduce_ex__() method in the super class, because the current behavior is expected when super() is used in the __reduce_ex__() implementation of some subclass. The super class likely should be registered in the global dispatch table.
There may be similar issue with shallow and deep copying.
Linked PRs
Feature or enhancement
As was noted in #125714 (comment), the
superobject is not pickleable. For example:Produces a traceback:
This is because the special methods like
__reduce_ex__()are looked up in an instance and translated to a lookup in the underlying object.This cannot be solved by implementing the
__reduce_ex__()method in thesuperclass, because the current behavior is expected whensuper()is used in the__reduce_ex__()implementation of some subclass. Thesuperclass likely should be registered in the global dispatch table.There may be similar issue with shallow and deep copying.
Linked PRs