[New-bugs-announce] [issue38214] __reduce__ API specs for objects with __slots__

Guido Imperiale report at bugs.python.org
Wed Sep 18 09:50:59 EDT 2019


New submission from Guido Imperiale <crusaderky at gmail.com>:

The documentation for the pickle module states, about the 3rd element of the tuple returned by __reduce__:

----

Optionally, the object’s state, which will be passed to the object’s __setstate__() method as previously described. If the object has no such method then, the value must be a dictionary and it will be added to the object’s __dict__ attribute.

----

This doesn't seem correct to me. It should instead read:

----

Optionally, the object’s state, which will be passed to the object’s __setstate__() method as previously described. If the object has no such method, then the value must be:

- for objects with only __dict__, a dictionary which will be used to update the object’s __dict__ attribute.
- for objects with only __slots__, a tuple of (None, {<__slots__ key>: <value>, ...})
- for objects with both __dict__ and __slots__, a tuple of ({<__dict__ key>: <value>, ...}, {<__slots__ key>: <value>, ...})

----

----------
assignee: docs at python
components: Documentation
messages: 352728
nosy: crusaderky, docs at python
priority: normal
severity: normal
status: open
title: __reduce__ API specs for objects with __slots__
type: behavior
versions: Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38214>
_______________________________________


More information about the New-bugs-announce mailing list