bpo-43340: Document possible UnicodeDecodeErrors from json.load()#25173
Closed
rhettinger wants to merge 1 commit into
Closed
bpo-43340: Document possible UnicodeDecodeErrors from json.load()#25173rhettinger wants to merge 1 commit into
rhettinger wants to merge 1 commit into
Conversation
|
|
||
| If the data being deserialized is not a valid JSON document, a | ||
| :exc:`JSONDecodeError` will be raised. | ||
| If the data being deserialized is not correctly encoded, a |
Member
There was a problem hiding this comment.
It should also be added for loads().
UnicodeDecodeError can only be raised for binary files. loads() for text never raise UnicodeDecodeError, and in case of load() for text file, UnicodeDecodeError and OSError can only be raised by the read() of the text file. There are many details, and without explaining them we will always get complqains about incomplete documentation, but adding all details will make the documentation too overloaded. We usually do not specify all exceptions which can be raised. Is there a good comromize?
Comment on lines
+270
to
+272
| If the data being deserialized is not correctly encoded, a | ||
| :exc:`UnicodeDecodeError` will be raised, and if the decoded file is not a | ||
| valid JSON document, a :exc:`JSONDecodeError` will be raised. |
Member
There was a problem hiding this comment.
Something like this?
Suggested change
| If the data being deserialized is not correctly encoded, a | |
| :exc:`UnicodeDecodeError` will be raised, and if the decoded file 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, and if the data is not a | |
| valid JSON document, a :exc:`JSONDecodeError` will be raised. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://bugs.python.org/issue43340