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.

classification
Title: Clarify documentation of __getinitargs__
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: David.Gilman, Mariatta, alexandre.vassalotti, berker.peksag, docs@python, serhiy.storchaka
Priority: normal Keywords: easy

Created on 2014-09-11 18:52 by David.Gilman, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 898 closed python-dev, 2017-03-30 05:53
PR 899 merged python-dev, 2017-03-30 05:55
Messages (4)
msg226795 - (view) Author: David Gilman (David.Gilman) * Date: 2014-09-11 18:52
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.
msg277670 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-09-28 22:27
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.
msg290817 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-03-30 06:07
See more detailed description in PEP 307.
msg290880 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-03-30 20:39
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/2ee01ecf419a392f0b6a33ca10d1f747adb6c43a
History
Date User Action Args
2022-04-11 14:58:07adminsetgithub: 66586
2017-03-30 20:40:21Mariattasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-03-30 20:39:08Mariattasetmessages: + msg290880
2017-03-30 06:08:02serhiy.storchakasetnosy: + alexandre.vassalotti
2017-03-30 06:07:11serhiy.storchakasetnosy: + serhiy.storchaka

messages: + msg290817
stage: needs patch -> patch review
2017-03-30 05:55:45python-devsetpull_requests: + pull_request801
2017-03-30 05:53:52python-devsetpull_requests: + pull_request800
2016-10-01 18:17:48Mariattasetnosy: + Mariatta
2016-09-28 22:27:03berker.peksagsetnosy: + berker.peksag
messages: + msg277670

keywords: + easy
stage: needs patch
2015-09-02 18:13:56serhiy.storchakalinkissue23639 dependencies
2014-09-11 18:52:32David.Gilmancreate