[New-bugs-announce] [issue10390] json.load should handle bytes input

Jeffrey Finkelstein report at bugs.python.org
Thu Nov 11 17:50:05 CET 2010

New submission from Jeffrey Finkelstein <jeffrey.finkelstein at gmail.com>:

The following code produces an error:

# APIKEY defined above
r = urllib.request.urlopen('http://api.billboard.com/apisvc/chart/v1/'
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().

components: Library (Lib)
messages: 120960
nosy: jfinkels
priority: normal
severity: normal
status: open
title: json.load should handle bytes input
type: feature request
versions: Python 3.2

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list