This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Expose default __getstate__ and __setstate__
Type: behavior Stage: resolved
Components: Versions:
Status: closed Resolution: duplicate
Dependencies: Superseder: Support pickling slots in subclasses of common classes
View: 26579
Assigned To: Nosy List: serhiy.storchaka, youkaichao
Priority: normal Keywords:

Created on 2020-08-14 04:57 by youkaichao, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg375369 - (view) Author: youkaichao (youkaichao) * Date: 2020-08-14 04:57
According to the doc ( ), an object may not have a __getstate__ method.

During pickling and unpickling, python first finds __getstate__ and __setstate__, which may invoke a customed __getattr__. I think this is unnecessary if python just provides a default implementation for __getstate__ / __setstate__ . An additional benefit of this is that __setstate__ and __getstate__ becomes available for every object and it is possible to do something like ``getstate(obj)``.

For people who customize __getattr__, I think no one intends to deal with ``obj.__getattr__(“__getstate__”)``, so it makes sense not to invoke ``__getattr__`` during pickling and unpickling.
msg375372 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-08-14 06:25
This is virtually a duplicate of isssue26579.
Date User Action Args
2022-04-11 14:59:34adminsetgithub: 85719
2020-08-14 06:25:45serhiy.storchakasetstatus: open -> closed

superseder: Support pickling slots in subclasses of common classes

nosy: + serhiy.storchaka
messages: + msg375372
resolution: duplicate
stage: resolved
2020-08-14 04:57:50youkaichaocreate