homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: json.load should handle bytes input
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.2
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: jfinkels, martin.panter
Priority: normal Keywords:

Created on 2010年11月11日 16:50 by jfinkels, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Messages (3)
msg120960 - (view) Author: Jeffrey Finkelstein (jfinkels) * Date: 2010年11月11日 16:50
The following code produces an error:
# APIKEY defined above
r = urllib.request.urlopen('http://api.billboard.com/apisvc/chart/v1/'
 'list/spec?api_key={}&format=JSON'
 .format(APIKEY))
j = json.load(r)
Specifically, the urlopen() function returns a request object that can be read, the request object returns a bytes object containing JSON, and the json.load() function tries to mix str and bytes objects when using the re module.
json.load() should convert bytes to str. It is reasonable that one should be able to open a url and pass the result directly to json.load().
msg120961 - (view) Author: Jeffrey Finkelstein (jfinkels) * Date: 2010年11月11日 16:53
Nevermind.
msg229972 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2014年10月25日 01:00
See also Issue 10976, discussing passing bytes() strings to json.loads()
History
Date User Action Args
2022年04月11日 14:57:08adminsetgithub: 54599
2014年10月25日 01:00:55martin.pantersetnosy: + martin.panter
messages: + msg229972
2010年11月11日 19:40:16r.david.murraysetstatus: open -> closed
stage: resolved
2010年11月11日 16:53:22jfinkelssetresolution: not a bug
messages: + msg120961
2010年11月11日 16:50:02jfinkelscreate

AltStyle によって変換されたページ (->オリジナル) /