[New-bugs-announce] [issue43340] json.load() can raise UnicodeDecodeError, but this is not documented

Matthew Woodcraft report at bugs.python.org
Sat Feb 27 13:24:21 EST 2021


New submission from Matthew Woodcraft <matthew at woodcraft.me.uk>:

The documentation for json.load() and json.loads() says:

« If the data being deserialized is not a valid JSON document, a JSONDecodeError will be raised. »

But this is not currently entirely true: if the data is provided in bytes form and is not properly encoded in one of the three accepted encodings, UnicodeDecodeError is raised instead.

(I have no opinion on whether the documentation or the behaviour should be changed.)

----------
components: Library (Lib)
messages: 387780
nosy: mattheww
priority: normal
severity: normal
status: open
title: json.load() can raise UnicodeDecodeError, but this is not documented
type: behavior
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43340>
_______________________________________


More information about the New-bugs-announce mailing list