gh-140793: Improve documentatation and tests for the ensure_ascii option in the json module (GH-140906)

* Document that ensure_ascii=True forces escaping not only non-ASCII, but also
  non-printable characters (the only affected ASCII character is U+007F).
* Ensure that the help output for the json module does not exceed 80
  columns (except one long line in an example and generated lines).
* Add more tests.
This commit is contained in:
Serhiy Storchaka 2025-11-08 12:07:27 +02:00 committed by GitHub
parent 8cec3d3a9d
commit 7e90bac3cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 89 additions and 43 deletions

View file

@ -297,10 +297,10 @@ def __init__(self, *, object_hook=None, parse_float=None,
place of the given ``dict``. This can be used to provide custom
deserializations (e.g. to support JSON-RPC class hinting).
``object_pairs_hook``, if specified will be called with the result of
every JSON object decoded with an ordered list of pairs. The return
value of ``object_pairs_hook`` will be used instead of the ``dict``.
This feature can be used to implement custom decoders.
``object_pairs_hook``, if specified will be called with the result
of every JSON object decoded with an ordered list of pairs. The
return value of ``object_pairs_hook`` will be used instead of the
``dict``. This feature can be used to implement custom decoders.
If ``object_hook`` is also defined, the ``object_pairs_hook`` takes
priority.