Skip to content

Commit

Permalink
[3.12] gh-87506: Document that json.load*() can raise UnicodeDecodeEr…
Browse files Browse the repository at this point in the history
…ror (GH-127355) (#128608)

(cherry picked from commit 15372d0)
(cherry picked from commit cdfb8bc)

Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్  రెడ్డి) <thatiparthysreenivas@gmail.com>
Co-authored-by: Erlend Aasland <erlend@python.org>
  • Loading branch information
3 people authored Jan 8, 2025
1 parent b46adda commit e903b8a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Doc/library/json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ Basic Usage
:raises JSONDecodeError:
When the data being deserialized is not a valid JSON document.

:raises UnicodeDecodeError:
When the data being deserialized does not contain
UTF-8, UTF-16 or UTF-32 encoded data.

.. versionchanged:: 3.1

* Added the optional *object_pairs_hook* parameter.
Expand All @@ -332,15 +336,11 @@ Basic Usage

.. 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`
Identical to :func:`load`, but instead of a file-like object,
deserialize *s* (a :class:`str`, :class:`bytes` or :class:`bytearray`
instance containing a JSON document) to a Python object using this
:ref:`conversion table <json-to-py-table>`.

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.

.. versionchanged:: 3.6
*s* can now be of type :class:`bytes` or :class:`bytearray`. The
input encoding should be UTF-8, UTF-16 or UTF-32.
Expand Down

0 comments on commit e903b8a

Please sign in to comment.