Skip to content
Myr

quickstart.rst: r.json() can raise JSONDecodeError on Py3

Before adoption: this commit came in with the history the project adopted, so no landing records it.

% `python2 -c "import requests ; requests.get('https://github.com').json()"` % `python3 -c "import requests ; requests.get('https://github.com').json()"`

authored by Christian Clauss · committed by GitHub · parent 913880c · Browse files · 1 file+3 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+3 added−1 removed

  • other:+3 added−1 removed

1 file+3 added−1 removed

modified:docs/user/quickstart.rst+3 added-1 removed
148 unmodified lines
149 [{'repository': {'open_issues': 0, 'url': 'https://github.com/...150151In case the JSON decoding fails, ``r.json()`` raises an exception. For example, if152the response gets a 204 (No Content), or if the response contains invalid JSON,153attempting ``r.json()`` raises ``ValueError: No JSON object could be decoded``.153attempting ``r.json()`` raises ``ValueError: No JSON object could be decoded`` on154Python 2 and raises ``simplejson.JSONDecodeError`` or ``json.JSONDecodeError`` on155Python 3.156157It should be noted that the success of the call to ``r.json()`` does **not**158indicate the success of the response. Some servers may return a JSON object in a159failed response (e.g. error details with HTTP 500). Such JSON will be decoded
407 unmodified lines