From c3b13c9913fe97971452e68da19d84e4ae0ef360 Mon Sep 17 00:00:00 2001 From: Srinivas Reddy Thatiparthy Date: Wed, 8 Jan 2025 12:19:44 +0530 Subject: [PATCH 1/6] gh-87506: Improve the documentation for json.load() and json.loads() --- Doc/library/json.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/library/json.rst b/Doc/library/json.rst index cf516cf3dc1d29..6e865c6ad0b872 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -323,6 +323,7 @@ Basic Usage :raises JSONDecodeError: When the data being deserialized is not a valid JSON document. + Or if the binary file does not contain UTF-8, UTF-16 or UTF-32 encoded data. .. versionchanged:: 3.1 @@ -349,8 +350,9 @@ Basic Usage 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. + If the data is not a valid JSON document, a :exc:`JSONDecodeError` will be + raised. If the binary file does not contain UTF-8, UTF-16 or UTF-32 encoded + data, a :exc:`UnicodeDecodeError` will be raised. .. versionchanged:: 3.6 *s* can now be of type :class:`bytes` or :class:`bytearray`. The From 6b271aa4f056b30df803e72d65a3ae560398b470 Mon Sep 17 00:00:00 2001 From: Srinivas Reddy Thatiparthy Date: Wed, 8 Jan 2025 12:50:43 +0530 Subject: [PATCH 2/6] Facepalm: fix the incorrect message --- Doc/library/json.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Doc/library/json.rst b/Doc/library/json.rst index 6e865c6ad0b872..5d8dba9e1ae0a8 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -323,7 +323,9 @@ Basic Usage :raises JSONDecodeError: When the data being deserialized is not a valid JSON document. - Or if the binary file does not contain UTF-8, UTF-16 or UTF-32 encoded data. + + : raises UnicodeDecodeError: + If the binary file does not contain UTF-8, UTF-16 or UTF-32 encoded data. .. versionchanged:: 3.1 From a433504b74953545222d721300238ea09a45df9e Mon Sep 17 00:00:00 2001 From: Srinivas Reddy Thatiparthy Date: Wed, 8 Jan 2025 12:52:48 +0530 Subject: [PATCH 3/6] Remove space --- Doc/library/json.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/json.rst b/Doc/library/json.rst index 5d8dba9e1ae0a8..7eb04dc462c32c 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -324,7 +324,7 @@ Basic Usage :raises JSONDecodeError: When the data being deserialized is not a valid JSON document. - : raises UnicodeDecodeError: + :raises UnicodeDecodeError: If the binary file does not contain UTF-8, UTF-16 or UTF-32 encoded data. .. versionchanged:: 3.1 From 08b8f3e8d39839c536a8c3a39f9ad5294b50a55c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Srinivas=20Reddy=20Thatiparthy=20=28=E0=B0=A4=E0=B0=BE?= =?UTF-8?q?=E0=B0=9F=E0=B0=BF=E0=B0=AA=E0=B0=B0=E0=B1=8D=E0=B0=A4=E0=B0=BF?= =?UTF-8?q?=20=E0=B0=B6=E0=B1=8D=E0=B0=B0=E0=B1=80=E0=B0=A8=E0=B0=BF?= =?UTF-8?q?=E0=B0=B5=E0=B0=BE=E0=B0=B8=E0=B1=8D=20=20=E0=B0=B0=E0=B1=86?= =?UTF-8?q?=E0=B0=A1=E0=B1=8D=E0=B0=A1=E0=B0=BF=29?= Date: Wed, 8 Jan 2025 12:55:35 +0530 Subject: [PATCH 4/6] Update Doc/library/json.rst Co-authored-by: Erlend E. Aasland --- Doc/library/json.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/json.rst b/Doc/library/json.rst index 7eb04dc462c32c..cb7d804a527729 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -325,7 +325,8 @@ Basic Usage When the data being deserialized is not a valid JSON document. :raises UnicodeDecodeError: - If the binary file does not contain UTF-8, UTF-16 or UTF-32 encoded data. + When the data being deserialized does not contain + UTF-8, UTF-16 or UTF-32 encoded data. .. versionchanged:: 3.1 From b7bd2b20eaffa221f76342df24e585482558ca86 Mon Sep 17 00:00:00 2001 From: Srinivas Reddy Thatiparthy Date: Wed, 8 Jan 2025 12:58:38 +0530 Subject: [PATCH 5/6] Address review comments --- Doc/library/json.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Doc/library/json.rst b/Doc/library/json.rst index cb7d804a527729..f96da46208663f 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -354,8 +354,7 @@ Basic Usage The other arguments have the same meaning as in :func:`load`. If the data is not a valid JSON document, a :exc:`JSONDecodeError` will be - raised. If the binary file does not contain UTF-8, UTF-16 or UTF-32 encoded - data, a :exc:`UnicodeDecodeError` will be raised. + raised. .. versionchanged:: 3.6 *s* can now be of type :class:`bytes` or :class:`bytearray`. The From 725e15518da6b001e3b20975c7fb1c3e78c0fcef Mon Sep 17 00:00:00 2001 From: Srinivas Reddy Thatiparthy Date: Wed, 8 Jan 2025 12:59:47 +0530 Subject: [PATCH 6/6] Address review comments --- Doc/library/json.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/json.rst b/Doc/library/json.rst index f96da46208663f..41a09b40d7e88b 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -353,8 +353,8 @@ Basic Usage The other arguments have the same meaning as in :func:`load`. - If the data is not a valid JSON document, a :exc:`JSONDecodeError` will be - raised. + 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