Fix #2673: JSON file encoding in absubmit

First, it's best to open the file as binary so the JSON module itself
can figure out how to decode it (it will just use UTF-8). Then, we can
use `load` instead of `loads` to avoid needing to read the file
explicitly ourselves.
This commit is contained in:
Adrian Sampson 2017-08-27 10:20:36 -04:00
parent 015aee3662
commit 34246a00e7
2 changed files with 4 additions and 2 deletions

View file

@ -133,8 +133,8 @@ class AcousticBrainzSubmitPlugin(plugins.BeetsPlugin):
item=item, error=e
)
return None
with open(filename) as tmp_file:
analysis = json.loads(tmp_file.read())
with open(filename, 'rb') as tmp_file:
analysis = json.load(tmp_file)
# Add the hash to the output.
analysis['metadata']['version']['essentia_build_sha'] = \
self.extractor_sha

View file

@ -35,6 +35,8 @@ Fixes:
music. :bug:`2667`
* :doc:`/plugins/chroma`: Fix a crash when running the ``submit`` command on
Python 3 on Windows with non-ASCII filenames. :bug:`2671`
* :doc:`/plugins/absubmit`: Fix an occasional crash on Python 3 when the AB
analysis tool produced non-ASCII metadata. :bug:`2673`
For developers: