[3.13] gh-123392: Clarify wording regarding parameters that are functions to be called (GH-123394) (GH-123664)

(cherry picked from commit c08ede2714)

Co-authored-by: ryan-duve <ryan-duve@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2024-09-05 12:49:51 +02:00 committed by GitHub
parent d8324335b5
commit 3765181359
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 36 additions and 38 deletions

View File

@ -241,28 +241,28 @@ Basic Usage
*object_hook* is an optional function that will be called with the result of *object_hook* is an optional function that will be called with the result of
any object literal decoded (a :class:`dict`). The return value of any object literal decoded (a :class:`dict`). The return value of
*object_hook* will be used instead of the :class:`dict`. This feature can be used *object_hook* will be used instead of the :class:`dict`. This feature can
to implement custom decoders (e.g. `JSON-RPC <https://www.jsonrpc.org>`_ be used to implement custom decoders (e.g. `JSON-RPC
class hinting). <https://www.jsonrpc.org>`_ class hinting).
*object_pairs_hook* is an optional function that will be called with the *object_pairs_hook* is an optional function that will be called with the
result of any object literal decoded with an ordered list of pairs. The result of any object literal decoded with an ordered list of pairs. The
return value of *object_pairs_hook* will be used instead of the return value of *object_pairs_hook* will be used instead of the
:class:`dict`. This feature can be used to implement custom decoders. :class:`dict`. This feature can be used to implement custom decoders. If
If *object_hook* is also defined, the *object_pairs_hook* takes priority. *object_hook* is also defined, the *object_pairs_hook* takes priority.
.. versionchanged:: 3.1 .. versionchanged:: 3.1
Added support for *object_pairs_hook*. Added support for *object_pairs_hook*.
*parse_float*, if specified, will be called with the string of every JSON *parse_float* is an optional function that will be called with the string of
float to be decoded. By default, this is equivalent to ``float(num_str)``. every JSON float to be decoded. By default, this is equivalent to
This can be used to use another datatype or parser for JSON floats ``float(num_str)``. This can be used to use another datatype or parser for
(e.g. :class:`decimal.Decimal`). JSON floats (e.g. :class:`decimal.Decimal`).
*parse_int*, if specified, will be called with the string of every JSON int *parse_int* is an optional function that will be called with the string of
to be decoded. By default, this is equivalent to ``int(num_str)``. This can every JSON int to be decoded. By default, this is equivalent to
be used to use another datatype or parser for JSON integers ``int(num_str)``. This can be used to use another datatype or parser for
(e.g. :class:`float`). JSON integers (e.g. :class:`float`).
.. versionchanged:: 3.11 .. versionchanged:: 3.11
The default *parse_int* of :func:`int` now limits the maximum length of The default *parse_int* of :func:`int` now limits the maximum length of
@ -270,10 +270,9 @@ Basic Usage
conversion length limitation <int_max_str_digits>` to help avoid denial conversion length limitation <int_max_str_digits>` to help avoid denial
of service attacks. of service attacks.
*parse_constant*, if specified, will be called with one of the following *parse_constant* is an optional function that will be called with one of the
strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. following strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. This can be
This can be used to raise an exception if invalid JSON numbers used to raise an exception if invalid JSON numbers are encountered.
are encountered.
.. versionchanged:: 3.1 .. versionchanged:: 3.1
*parse_constant* doesn't get called on 'null', 'true', 'false' anymore. *parse_constant* doesn't get called on 'null', 'true', 'false' anymore.
@ -345,34 +344,33 @@ Encoders and Decoders
It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as their It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as their
corresponding ``float`` values, which is outside the JSON spec. corresponding ``float`` values, which is outside the JSON spec.
*object_hook*, if specified, will be called with the result of every JSON *object_hook* is an optional function that will be called with the result of
object decoded and its return value will be used in place of the given every JSON object decoded and its return value will be used in place of the
:class:`dict`. This can be used to provide custom deserializations (e.g. to given :class:`dict`. This can be used to provide custom deserializations
support `JSON-RPC <https://www.jsonrpc.org>`_ class hinting). (e.g. to support `JSON-RPC <https://www.jsonrpc.org>`_ class hinting).
*object_pairs_hook*, if specified will be called with the result of every *object_pairs_hook* is an optional function that will be called with the
JSON object decoded with an ordered list of pairs. The return value of result of every JSON object decoded with an ordered list of pairs. The
*object_pairs_hook* will be used instead of the :class:`dict`. This return value of *object_pairs_hook* will be used instead of the
feature can be used to implement custom decoders. If *object_hook* is also :class:`dict`. This feature can be used to implement custom decoders. If
defined, the *object_pairs_hook* takes priority. *object_hook* is also defined, the *object_pairs_hook* takes priority.
.. versionchanged:: 3.1 .. versionchanged:: 3.1
Added support for *object_pairs_hook*. Added support for *object_pairs_hook*.
*parse_float*, if specified, will be called with the string of every JSON *parse_float* is an optional function that will be called with the string of
float to be decoded. By default, this is equivalent to ``float(num_str)``. every JSON float to be decoded. By default, this is equivalent to
This can be used to use another datatype or parser for JSON floats ``float(num_str)``. This can be used to use another datatype or parser for
(e.g. :class:`decimal.Decimal`). JSON floats (e.g. :class:`decimal.Decimal`).
*parse_int*, if specified, will be called with the string of every JSON int *parse_int* is an optional function that will be called with the string of
to be decoded. By default, this is equivalent to ``int(num_str)``. This can every JSON int to be decoded. By default, this is equivalent to
be used to use another datatype or parser for JSON integers ``int(num_str)``. This can be used to use another datatype or parser for
(e.g. :class:`float`). JSON integers (e.g. :class:`float`).
*parse_constant*, if specified, will be called with one of the following *parse_constant* is an optional function that will be called with one of the
strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. following strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. This can be
This can be used to raise an exception if invalid JSON numbers used to raise an exception if invalid JSON numbers are encountered.
are encountered.
If *strict* is false (``True`` is the default), then control characters If *strict* is false (``True`` is the default), then control characters
will be allowed inside strings. Control characters in this context are will be allowed inside strings. Control characters in this context are