Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

There are other heap types implemented in C in the stdlib and third-party 
libraries for which pickling with protocols 0 and 1 works incorrectly. It would 
be better to fix copyreg._reduce_ex() instead of disabling pickling for these 
types one by one.

>From PEP 307:


> Let D be the class on the object to be pickled. First, find the nearest base 
> class that is implemented in C (either as a built-in type or as a type 
> defined by an extension class). Call this base class B, and the class of the 
> object to be pickled D. Unless B is the class 'object', instances of class B 
> must be picklable, either by having built-in support (as defined in the above 
> three bullet points), or by having a non-default __reduce__ implementation. B 
> must not be the same class as D (if it were, it would mean that D is not 
> implemented in Python).

The problem is with determining which class is implemented in C. The current 
code implies that heap types are implemented in Python, and static types are 
implemented in C. It is not always true, because some heap types can be 
implemented in C.

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41052>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to