classification
Title: JSONDecoder should document that it raises a ValueError for malformed data
Type: enhancement Stage: needs patch
Components: Documentation Versions: Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: corey, docs@python, felixc, python-dev, wolever
Priority: normal Keywords: easy, patch

Created on 2013-08-07 22:06 by corey, last changed 2013-08-12 22:28 by python-dev. This issue is now closed.

Files
File name Uploaded Description Edit
18680.patch felixc, 2013-08-12 21:47
Messages (5)
msg194628 - (view) Author: Corey Farwell (corey) Date: 2013-08-07 22:06
Before someone comes in and tries to correct me, I know Python documentation is different than Javadocs. It is common to test if the JSON is malformed using a try...catch. What if I want to catch something more specific than Exception? The only way a user would know what to catch is to `python -c "import json; json.loads('FAIL')"`. Many other Python modules document which exception is raised on invalid input/parameters.
msg194629 - (view) Author: Corey Farwell (corey) Date: 2013-08-07 22:13
Ideally, this would also be decoumented in json.loads/json.load
msg195026 - (view) Author: Felix Crux (felixc) * Date: 2013-08-12 21:47
Working with wolever on the process, generated the attached patch.
msg195031 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-08-12 22:13
New changeset f11683963558 by Felix Crux in branch 'default':
Documenting that json.load may raise a ValueError.
http://hg.python.org/cpython/rev/f11683963558

New changeset 905fad4cb40a by Felix Crux in branch 'default':
Documenting that json.load may raise a ValueError.
http://hg.python.org/cpython/rev/905fad4cb40a

New changeset 7ba77d77b499 by Felix Crux in branch 'default':
Documenting that json.load may raise a ValueError.
http://hg.python.org/cpython/rev/7ba77d77b499
msg195033 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-08-12 22:28
New changeset f8cf0f997dfa by Felix Crux in branch '3.3':
Documenting that json.load may raise a ValueError.
http://hg.python.org/cpython/rev/f8cf0f997dfa

New changeset 524693d62093 by Felix Crux in branch '2.7':
Documenting that json.load may raise a ValueError.
http://hg.python.org/cpython/rev/524693d62093
History
Date User Action Args
2013-08-12 22:28:26python-devsetmessages: + msg195033
2013-08-12 22:15:21woleversetstatus: open -> closed
resolution: fixed
2013-08-12 22:13:38python-devsetnosy: + python-dev
messages: + msg195031
2013-08-12 21:47:04felixcsetfiles: + 18680.patch

nosy: + felixc, wolever
messages: + msg195026

keywords: + patch
2013-08-08 17:47:56pitrousetkeywords: + easy
stage: needs patch
versions: - Python 2.6, Python 3.1, Python 3.2, Python 3.5
2013-08-07 22:13:09coreysetmessages: + msg194629
2013-08-07 22:06:31coreycreate