From 8ccca753e8b178ef36953f863dfbfd984eba9d67 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Sun, 13 May 2018 14:20:21 -0700 Subject: [PATCH] bpo-33461:remove json.loads encoding kwarg The keyword argument was deprecated in 3.1, and can now be removed. --- Doc/library/json.rst | 5 ++--- Lib/json/__init__.py | 3 +-- .../next/Library/2018-05-13-14-19-13.bpo-33461.uteyf-.rst | 2 ++ 3 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2018-05-13-14-19-13.bpo-33461.uteyf-.rst diff --git a/Doc/library/json.rst b/Doc/library/json.rst index 85798fa2cf723a7..f6ad1f1f07f2cd5 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -262,14 +262,13 @@ Basic Usage .. versionchanged:: 3.6 All optional parameters are now :ref:`keyword-only `. -.. function:: loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw) +.. function:: loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw) Deserialize *s* (a :class:`str`, :class:`bytes` or :class:`bytearray` instance containing a JSON document) to a Python object using this :ref:`conversion table `. - The other arguments have the same meaning as in :func:`load`, except - *encoding* which is ignored and deprecated. + The other arguments have the same meaning as in :func:`load`. If the data being deserialized is not a valid JSON document, a :exc:`JSONDecodeError` will be raised. diff --git a/Lib/json/__init__.py b/Lib/json/__init__.py index 3bb4490e818ba03..8a0fa66af6be24f 100644 --- a/Lib/json/__init__.py +++ b/Lib/json/__init__.py @@ -296,7 +296,7 @@ def load(fp, *, cls=None, object_hook=None, parse_float=None, parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw) -def loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None, +def loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw): """Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` instance containing a JSON document) to a Python object. @@ -330,7 +330,6 @@ def loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None, To use a custom ``JSONDecoder`` subclass, specify it with the ``cls`` kwarg; otherwise ``JSONDecoder`` is used. - The ``encoding`` argument is ignored and deprecated. """ if isinstance(s, str): if s.startswith('\ufeff'): diff --git a/Misc/NEWS.d/next/Library/2018-05-13-14-19-13.bpo-33461.uteyf-.rst b/Misc/NEWS.d/next/Library/2018-05-13-14-19-13.bpo-33461.uteyf-.rst new file mode 100644 index 000000000000000..e58c69977e75541 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-05-13-14-19-13.bpo-33461.uteyf-.rst @@ -0,0 +1,2 @@ +json.loads *encoding* keyword which was deprecated and ignored since Python +3.1 has been removed