Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 531d1e5

Browse files
bpo-39435: Make the first argument of pickle.loads() positional-only. (GH-19846)
It was positional-only de facto: documentation and two implementations used three different name.
1 parent d2baff4 commit 531d1e5

5 files changed

Lines changed: 9 additions & 7 deletions

File tree

Doc/library/pickle.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ process more convenient:
252252
.. versionchanged:: 3.8
253253
The *buffers* argument was added.
254254

255-
.. function:: loads(data, \*, fix_imports=True, encoding="ASCII", errors="strict", buffers=None)
255+
.. function:: loads(data, /, \*, fix_imports=True, encoding="ASCII", errors="strict", buffers=None)
256256

257257
Return the reconstituted object hierarchy of the pickled representation
258258
*data* of an object. *data* must be a :term:`bytes-like object`.

Lib/pickle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
dump(object, file)
1414
dumps(object) -> string
1515
load(file) -> object
16-
loads(string) -> object
16+
loads(bytes) -> object
1717
1818
Misc variables:
1919
@@ -1761,7 +1761,7 @@ def _load(file, *, fix_imports=True, encoding="ASCII", errors="strict",
17611761
return _Unpickler(file, fix_imports=fix_imports, buffers=buffers,
17621762
encoding=encoding, errors=errors).load()
17631763

1764-
def _loads(s, *, fix_imports=True, encoding="ASCII", errors="strict",
1764+
def _loads(s, /, *, fix_imports=True, encoding="ASCII", errors="strict",
17651765
buffers=None):
17661766
if isinstance(s, str):
17671767
raise TypeError("Can't load pickle from unicode string")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The first argument of :func:`pickle.loads` is now positional-only.

Modules/_pickle.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7873,6 +7873,7 @@ _pickle_load_impl(PyObject *module, PyObject *file, int fix_imports,
78737873
_pickle.loads
78747874
78757875
data: object
7876+
/
78767877
*
78777878
fix_imports: bool = True
78787879
encoding: str = 'ASCII'
@@ -7899,7 +7900,7 @@ static PyObject *
78997900
_pickle_loads_impl(PyObject *module, PyObject *data, int fix_imports,
79007901
const char *encoding, const char *errors,
79017902
PyObject *buffers)
7902-
/*[clinic end generated code: output=82ac1e6b588e6d02 input=9c2ab6a0960185ea]*/
7903+
/*[clinic end generated code: output=82ac1e6b588e6d02 input=b3615540d0535087]*/
79037904
{
79047905
PyObject *result;
79057906
UnpicklerObject *unpickler = _Unpickler_New();

Modules/clinic/_pickle.c.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)