summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-06-21 21:03:20 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-06-21 21:03:20 (GMT)
commitaacd53f6cb96fe8c4fe9ce894f22e25f356a97c3 (patch)
tree4ba936a620bf3170ae9c7f74c35bf52142e40288 /Doc
parent43354375063662deda272b9a2d64cf53d6b748f3 (diff)
downloadcpython-aacd53f6cb96fe8c4fe9ce894f22e25f356a97c3.zip
cpython-aacd53f6cb96fe8c4fe9ce894f22e25f356a97c3.tar.gz
cpython-aacd53f6cb96fe8c4fe9ce894f22e25f356a97c3.tar.bz2
Issue #18726: All optional parameters of the dump(), dumps(),
load() and loads() functions and JSONEncoder and JSONDecoder class constructors in the json module are now keyword-only.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/json.rst24
-rw-r--r--Doc/whatsnew/3.6.rst8
2 files changed, 26 insertions, 6 deletions
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index 174e734..55ec1e9 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -126,7 +126,7 @@ See :ref:`json-commandline` for detailed documentation.
Basic Usage
-----------
-.. function:: dump(obj, fp, skipkeys=False, ensure_ascii=True, \
+.. function:: dump(obj, fp, *, skipkeys=False, ensure_ascii=True, \
check_circular=True, allow_nan=True, cls=None, \
indent=None, separators=None, default=None, \
sort_keys=False, **kw)
@@ -184,8 +184,11 @@ Basic Usage
:meth:`default` method to serialize additional types), specify it with the
*cls* kwarg; otherwise :class:`JSONEncoder` is used.
+ .. versionchanged:: 3.6
+ All optional parameters are now :ref:`keyword-only <keyword-only_parameter>`.
-.. function:: dumps(obj, skipkeys=False, ensure_ascii=True, \
+
+.. function:: dumps(obj, *, skipkeys=False, ensure_ascii=True, \
check_circular=True, allow_nan=True, cls=None, \
indent=None, separators=None, default=None, \
sort_keys=False, **kw)
@@ -209,7 +212,7 @@ Basic Usage
the original one. That is, ``loads(dumps(x)) != x`` if x has non-string
keys.
-.. function:: load(fp, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
+.. function:: load(fp, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
Deserialize *fp* (a ``.read()``-supporting :term:`file-like object`
containing a JSON document) to a Python object using this :ref:`conversion
@@ -257,7 +260,10 @@ Basic Usage
If the data being deserialized is not a valid JSON document, a
:exc:`JSONDecodeError` will be raised.
-.. function:: loads(s, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
+ .. versionchanged:: 3.6
+ All optional parameters are now :ref:`keyword-only <keyword-only_parameter>`.
+
+.. function:: loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
Deserialize *s* (a :class:`str` instance containing a JSON document) to a
Python object using this :ref:`conversion table <json-to-py-table>`.
@@ -271,7 +277,7 @@ Basic Usage
Encoders and Decoders
---------------------
-.. class:: JSONDecoder(object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)
+.. class:: JSONDecoder(*, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)
Simple JSON decoder.
@@ -341,6 +347,9 @@ Encoders and Decoders
If the data being deserialized is not a valid JSON document, a
:exc:`JSONDecodeError` will be raised.
+ .. versionchanged:: 3.6
+ All parameters are now :ref:`keyword-only <keyword-only_parameter>`.
+
.. method:: decode(s)
Return the Python representation of *s* (a :class:`str` instance
@@ -359,7 +368,7 @@ Encoders and Decoders
extraneous data at the end.
-.. class:: JSONEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)
+.. class:: JSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)
Extensible JSON encoder for Python data structures.
@@ -438,6 +447,9 @@ Encoders and Decoders
otherwise be serialized. It should return a JSON encodable version of the
object or raise a :exc:`TypeError`.
+ .. versionchanged:: 3.6
+ All parameters are now :ref:`keyword-only <keyword-only_parameter>`.
+
.. method:: default(o)
diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst
index 9a21912..177b17f 100644
--- a/Doc/whatsnew/3.6.rst
+++ b/Doc/whatsnew/3.6.rst
@@ -685,6 +685,14 @@ Changes in the Python API
Code that has already been updated in accordance with the deprecation
warning generated by 3.5 will not be affected.
+* All optional parameters of the :func:`~json.dump`, :func:`~json.dumps`,
+ :func:`~json.load` and :func:`~json.loads` functions and
+ :class:`~json.JSONEncoder` and :class:`~json.JSONDecoder` class
+ constructors in the :mod:`json` module are now :ref:`keyword-only
+ <keyword-only_parameter>`.
+ (Contributed by Serhiy Storchaka in :issue:`18726`.)
+
+
Changes in the C API
--------------------