[issue22392] Clarify documentation of __getinitargs__
New submission from David Gilman: Implementations of __getinitargs__ return a tuple of the positional arguments for __init__. This wasn't initially apparent to me after reading the docs: I thought you were passing a tuple (args, kwargs) that would get called f(*args, **kwargs) and had to go to the pickle implementation to find out what you were supposed to do. The proposed documentation enhancement: mention that you're just supposed to return a tuple of positional args and that it doesn't support kwargs. ---------- assignee: docs@python components: Documentation messages: 226795 nosy: David.Gilman, docs@python priority: normal severity: normal status: open title: Clarify documentation of __getinitargs__ type: enhancement versions: Python 2.7 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue22392> _______________________________________
Berker Peksag added the comment: https://docs.python.org/2/library/pickle.html#object.__getinitargs__ states: "If it is desirable that the __init__() method be called on unpickling, an old-style class can define a method __getinitargs__(), which should return a tuple containing the arguments to be passed to the class constructor (__init__() for example)." However, there is no mention that it only accepts positional arguments. This is a Python 2-only change and the documentation file is located at Doc/library/pickle.rst in 2.7 branch. ---------- keywords: +easy nosy: +berker.peksag stage: -> needs patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue22392> _______________________________________
Changes by Mariatta Wijaya <mariatta.wijaya@gmail.com>: ---------- nosy: +Mariatta _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue22392> _______________________________________
Changes by Roundup Robot <devnull@psf.upfronthosting.co.za>: ---------- pull_requests: +800 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue22392> _______________________________________
Changes by Roundup Robot <devnull@psf.upfronthosting.co.za>: ---------- pull_requests: +801 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue22392> _______________________________________
Serhiy Storchaka added the comment: See more detailed description in PEP 307. ---------- nosy: +serhiy.storchaka stage: needs patch -> patch review _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue22392> _______________________________________
Changes by Serhiy Storchaka <storchaka+cpython@gmail.com>: ---------- nosy: +alexandre.vassalotti _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue22392> _______________________________________
Mariatta Wijaya added the comment: New changeset 2ee01ecf419a392f0b6a33ca10d1f747adb6c43a by Mariatta (Mandeep Singh) in branch '2.7': [2.7] bpo-22392: Improve documentation for __getinitargs__ (GH-899) https://github.com/python/cpython/commit/2ee01ecf419a392f0b6a33ca10d1f747adb... ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue22392> _______________________________________
Changes by Mariatta Wijaya <mariatta.wijaya@gmail.com>: ---------- resolution: -> fixed stage: patch review -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue22392> _______________________________________
participants (5)
-
Berker Peksag
-
David Gilman
-
Mariatta Wijaya
-
Roundup Robot
-
Serhiy Storchaka