[issue39435] pickle: inconsistent arguments pickle.py vs _pickle.c vs docs
New submission from Guido Imperiale <crusaderky@gmail.com>: (1) In the documentation for loads(), the name for the first argument of loads is 'bytes_object'. The actual signature, both in pickle.py and _pickle.c, it is instead 'data'. (2) In the documentation and in pickle.py, the default value for the 'buffers' parameter is None. However, in _pickle.c, it is an empty tuple (); this is also reflected by running the interpreter: In [1]: inspect.signature(pickle.loads).parameters['buffers'] Out[1]: <Parameter "buffers=()"> Thanks to @hauntsaninja for spotting these in https://github.com/python/typeshed/pull/3636 ---------- assignee: docs@python components: Documentation, Library (Lib) messages: 360569 nosy: crusaderky, docs@python priority: normal severity: normal status: open title: pickle: inconsistent arguments pickle.py vs _pickle.c vs docs versions: Python 3.8 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39435> _______________________________________
Change by Karthikeyan Singaravelan <tir.karthi@gmail.com>: ---------- nosy: +pitrou _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39435> _______________________________________
Change by Roundup Robot <devnull@psf.upfronthosting.co.za>: ---------- keywords: +patch pull_requests: +17547 stage: -> patch review pull_request: https://github.com/python/cpython/pull/18160 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39435> _______________________________________
Antoine Pitrou <pitrou@free.fr> added the comment: As mentioned on the attached PR, the first argument is positional, so it doesn't matter that the name in the docs is not the same as the name in the code. The name "bytes_object" makes it clear which type of object is accepted, which makes it a better fit IMHO than "data". Therefore, I'm going to close this issue. ---------- resolution: -> not a bug stage: patch review -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39435> _______________________________________
Antoine Pitrou <pitrou@free.fr> added the comment: Reopening because it seems my reading of the doc was wrong (took a backslash for a regular slash :-o). ---------- resolution: not a bug -> stage: resolved -> status: closed -> open _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39435> _______________________________________
Serhiy Storchaka <storchaka+cpython@gmail.com> added the comment: In pickle.py the name of the first parameter is "s" (it was "str" in 2.7), not "data". And in the module docstring it is "string". So we have two options: 1. Make the first parameter positional-only. This is not breaking change because the documentation and two implementations had four different names, so there was no official way to pass it by keyword. 2. Make it positional-and-keyword parameter officially. All implementations, documentation and docstrings should be synchronized. What is more preferable? Do we need to pass the first argument to pickle.loads() by keyword? After resolving this issue we may want to revise other modules which have the loads() function. ---------- nosy: +serhiy.storchaka _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39435> _______________________________________
Change by Serhiy Storchaka <storchaka+cpython@gmail.com>: ---------- type: -> enhancement versions: +Python 3.9 -Python 3.8 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39435> _______________________________________
miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset 289842ae820f99908d3a345f1f3b6d4e5b4b97fc by Shantanu in branch 'master': bpo-39435: Fix docs for pickle.loads (GH-18160) https://github.com/python/cpython/commit/289842ae820f99908d3a345f1f3b6d4e5b4... ---------- nosy: +miss-islington _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39435> _______________________________________
Change by Antoine Pitrou <solipsis@pitrou.net>: ---------- pull_requests: +19161 stage: -> patch review pull_request: https://github.com/python/cpython/pull/19843 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39435> _______________________________________
Change by Antoine Pitrou <solipsis@pitrou.net>: ---------- pull_requests: +19162 pull_request: https://github.com/python/cpython/pull/19844 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39435> _______________________________________
miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset 3859b1ac1d7014f8ff673962d94a01a408546e24 by Antoine Pitrou in branch '3.7': [3.7] bpo-39435: Fix docs for pickle.loads (GH-18160). (GH-19844) https://github.com/python/cpython/commit/3859b1ac1d7014f8ff673962d94a01a4085... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39435> _______________________________________
miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset e05828055e5165cc7268ea3bea33adc502e054a1 by Antoine Pitrou in branch '3.8': [3.8] bpo-39435: Fix docs for pickle.loads (GH-18160) (GH-19843) https://github.com/python/cpython/commit/e05828055e5165cc7268ea3bea33adc502e... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39435> _______________________________________
Change by Antoine Pitrou <solipsis@pitrou.net>: ---------- resolution: -> fixed stage: patch review -> resolved status: open -> closed versions: +Python 3.7, Python 3.8 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39435> _______________________________________
Change by Serhiy Storchaka <storchaka+cpython@gmail.com>: ---------- pull_requests: +19164 pull_request: https://github.com/python/cpython/pull/19846 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39435> _______________________________________
Serhiy Storchaka <storchaka+cpython@gmail.com> added the comment: New changeset 531d1e541284bfd7944f8c66a5e8c3c3234afaff by Serhiy Storchaka in branch 'master': bpo-39435: Make the first argument of pickle.loads() positional-only. (GH-19846) https://github.com/python/cpython/commit/531d1e541284bfd7944f8c66a5e8c3c3234... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39435> _______________________________________
participants (6)
-
Antoine Pitrou
-
Guido Imperiale
-
Karthikeyan Singaravelan
-
miss-islington
-
Roundup Robot
-
Serhiy Storchaka