Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_release_group_image_list raises "TypeError: the JSON object must be str, not 'bytes'" on Python 3.5 #208

Closed
mbaechtold opened this issue Sep 15, 2016 · 1 comment

Comments

@mbaechtold
Copy link

mbaechtold commented Sep 15, 2016

I'm getting an exception when I try to execute musicbrainzngs.get_release_group_image_list('77ea502e-5e73-469f-8a09-4994ab55a93c') (release 0.6) on Python 3.5:

File "/path/to/virtualenv/lib/python3.5/site-packages/musicbrainzngs/caa.py", line 116, in get_release_group_image_list
    return _caa_request(releasegroupid, entitytype="release-group")
File "/path/to/virtualenv/lib/python3.5/site-packages/musicbrainzngs/caa.py", line 77, in _caa_request
    if imageid:
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'
mineo added a commit to mineo/python-musicbrainz-ngs that referenced this issue Sep 15, 2016
HTTPResponse.read() always returns bytes, but json.loads expects a
str (or unicode) object. On Python 2, this conversion happened
automatically, on Python 3, it didn't, so do it explicitly.

This also fixes the tests to return bytes rather than str.

Fixes alastair#208.

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
mineo added a commit to mineo/python-musicbrainz-ngs that referenced this issue Sep 15, 2016
HTTPResponse.read() always returns bytes, but json.loads expects a
str (or unicode) object. On Python 2, this conversion happened
automatically, on Python 3, it didn't, so do it explicitly.

Fixes alastair#208.

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
mineo added a commit to mineo/python-musicbrainz-ngs that referenced this issue Sep 15, 2016
HTTPResponse.read() always returns bytes, but json.loads expects a
str (or unicode) object. On Python 2, this conversion happened
automatically, on Python 3, it didn't, so do it explicitly.

Fixes alastair#208.

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
@mineo
Copy link
Collaborator

mineo commented Sep 15, 2016

Oh boy, that's emberassing, I wonder if that code ever worked on Python 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants