Pierre Glaser <pierregla...@msn.com> added the comment:
It turns out that both pickle and _pickle implement this feature, but the behavior is inconsistent. - As a reminder, instances of slotted classes do not have a dict attribute (1) - On the other side, when pickling slotted class instances, __getstate__ can return a tuple of 2 dicts. The first dict represents the __dict__ attribute. Because of (1), this first dict should simply be a sentinel value. In pickle, the condition is that it evaluates to False, but in _pickle, it should be explicitly None. (- Finally, The second dict in state contains the slotted attribute. ) Here are the lines in the two files causing the inconsistent behavior: https://github.com/python/cpython/blob/master/Modules/_pickle.c#L6236 https://github.com/python/cpython/blob/master/Lib/pickle.py#L1549 I included an example that illustrates it. ---------- Added file: https://bugs.python.org/file48111/test_slots.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35933> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com