Skip to content

Commit 27a1cda

Browse files
[3.12] gh-87506: Document that json.load*() can raise UnicodeDecodeError (GH-127355)
(cherry picked from commit 15372d0) Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) <[email protected]> Co-authored-by: Erlend Aasland <[email protected]>
1 parent b46adda commit 27a1cda

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Doc/library/json.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ Basic Usage
313313
:raises JSONDecodeError:
314314
When the data being deserialized is not a valid JSON document.
315315

316+
:raises UnicodeDecodeError:
317+
When the data being deserialized does not contain
318+
UTF-8, UTF-16 or UTF-32 encoded data.
319+
316320
.. versionchanged:: 3.1
317321

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

333337
.. function:: loads(s, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)
334338

335-
Deserialize *s* (a :class:`str`, :class:`bytes` or :class:`bytearray`
339+
Identical to :func:`load`, but instead of a file-like object,
340+
deserialize *s* (a :class:`str`, :class:`bytes` or :class:`bytearray`
336341
instance containing a JSON document) to a Python object using this
337342
:ref:`conversion table <json-to-py-table>`.
338343

339-
The other arguments have the same meaning as in :func:`load`.
340-
341-
If the data being deserialized is not a valid JSON document, a
342-
:exc:`JSONDecodeError` will be raised.
343-
344344
.. versionchanged:: 3.6
345345
*s* can now be of type :class:`bytes` or :class:`bytearray`. The
346346
input encoding should be UTF-8, UTF-16 or UTF-32.

0 commit comments

Comments
 (0)