summaryrefslogtreecommitdiff
path: root/Doc/library/pickle.rst
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-10-13 21:26:35 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2015-10-13 21:26:35 +0300
commitb6d84832bfa1f453d3c73d6db0982aee0e6d04fe (patch)
tree9663ebde6b6dd89fd66e36f9886a55119695c65f /Doc/library/pickle.rst
parentdbc517c2dd273f70d2608fd514477fbac459fcab (diff)
downloadcpython-git-b6d84832bfa1f453d3c73d6db0982aee0e6d04fe.tar.gz
Issue #24164: Document changes to __getnewargs__ and __getnewargs_ex__.
Diffstat (limited to 'Doc/library/pickle.rst')
-rw-r--r--Doc/library/pickle.rst19
1 files changed, 13 insertions, 6 deletions
diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst
index f862065ac5..2aab909180 100644
--- a/Doc/library/pickle.rst
+++ b/Doc/library/pickle.rst
@@ -488,7 +488,7 @@ methods:
.. method:: object.__getnewargs_ex__()
- In protocols 4 and newer, classes that implements the
+ In protocols 2 and newer, classes that implements the
:meth:`__getnewargs_ex__` method can dictate the values passed to the
:meth:`__new__` method upon unpickling. The method must return a pair
``(args, kwargs)`` where *args* is a tuple of positional arguments
@@ -500,15 +500,22 @@ methods:
class requires keyword-only arguments. Otherwise, it is recommended for
compatibility to implement :meth:`__getnewargs__`.
+ .. versionchanged:: 3.6
+ :meth:`__getnewargs_ex__` is now used in protocols 2 and 3.
+
.. method:: object.__getnewargs__()
- This method serve a similar purpose as :meth:`__getnewargs_ex__` but
- for protocols 2 and newer. It must return a tuple of arguments ``args``
- which will be passed to the :meth:`__new__` method upon unpickling.
+ This method serve a similar purpose as :meth:`__getnewargs_ex__`, but
+ supports only positional arguments. It must return a tuple of arguments
+ ``args`` which will be passed to the :meth:`__new__` method upon unpickling.
+
+ :meth:`__getnewargs__` will not be called if :meth:`__getnewargs_ex__` is
+ defined.
- In protocols 4 and newer, :meth:`__getnewargs__` will not be called if
- :meth:`__getnewargs_ex__` is defined.
+ .. versionchanged:: 3.6
+ Before Python 3.6, :meth:`__getnewargs__` was called instead of
+ :meth:`__getnewargs_ex__` in protocols 2 and 3.
.. method:: object.__getstate__()