[issue18680] JSONDecoder should document that it raises a ValueError for malformed data
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
New submission from Corey Farwell: 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. ---------- assignee: docs@python components: Documentation messages: 194628 nosy: corey, docs@python priority: normal severity: normal status: open title: JSONDecoder should document that it raises a ValueError for malformed data type: enhancement versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18680> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Corey Farwell added the comment: Ideally, this would also be decoumented in json.loads/json.load ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18680> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Changes by Antoine Pitrou <pitrou@free.fr>: ---------- keywords: +easy stage: -> needs patch versions: -Python 2.6, Python 3.1, Python 3.2, Python 3.5 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18680> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Felix Crux added the comment: Working with wolever on the process, generated the attached patch. ---------- keywords: +patch nosy: +felixc, wolever Added file: http://bugs.python.org/file31263/18680.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18680> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Roundup Robot added the comment: 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 ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18680> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Changes by David Wolever <david@wolever.net>: ---------- resolution: -> fixed status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18680> _______________________________________
![](https://secure.gravatar.com/avatar/fa0f7819f1825f596b384c19aa7dcf33.jpg?s=120&d=mm&r=g)
Roundup Robot added the comment: 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 ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue18680> _______________________________________
participants (5)
-
Antoine Pitrou
-
Corey Farwell
-
David Wolever
-
Felix Crux
-
Roundup Robot