mirror of
https://github.com/python/cpython.git
synced 2025-11-14 07:49:28 +00:00
Issue #24164: Document changes to __getnewargs__ and __getnewargs_ex__.
This commit is contained in:
parent
dbc517c2dd
commit
b6d84832bf
1 changed files with 13 additions and 6 deletions
|
|
@ -488,7 +488,7 @@ methods:
|
||||||
|
|
||||||
.. method:: object.__getnewargs_ex__()
|
.. 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:`__getnewargs_ex__` method can dictate the values passed to the
|
||||||
:meth:`__new__` method upon unpickling. The method must return a pair
|
:meth:`__new__` method upon unpickling. The method must return a pair
|
||||||
``(args, kwargs)`` where *args* is a tuple of positional arguments
|
``(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
|
class requires keyword-only arguments. Otherwise, it is recommended for
|
||||||
compatibility to implement :meth:`__getnewargs__`.
|
compatibility to implement :meth:`__getnewargs__`.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.6
|
||||||
|
:meth:`__getnewargs_ex__` is now used in protocols 2 and 3.
|
||||||
|
|
||||||
|
|
||||||
.. method:: object.__getnewargs__()
|
.. method:: object.__getnewargs__()
|
||||||
|
|
||||||
This method serve a similar purpose as :meth:`__getnewargs_ex__` but
|
This method serve a similar purpose as :meth:`__getnewargs_ex__`, but
|
||||||
for protocols 2 and newer. It must return a tuple of arguments ``args``
|
supports only positional arguments. It must return a tuple of arguments
|
||||||
which will be passed to the :meth:`__new__` method upon unpickling.
|
``args`` which will be passed to the :meth:`__new__` method upon unpickling.
|
||||||
|
|
||||||
In protocols 4 and newer, :meth:`__getnewargs__` will not be called if
|
:meth:`__getnewargs__` will not be called if :meth:`__getnewargs_ex__` is
|
||||||
:meth:`__getnewargs_ex__` is defined.
|
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__()
|
.. method:: object.__getstate__()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue