Skip to content

Commit

Permalink
Fix #2673: JSON file encoding in absubmit
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sampsyo committed Aug 27, 2017
1 parent 015aee3 commit 34246a0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions beetsplug/absubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ def _get_analysis(self, item):
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
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down

0 comments on commit 34246a0

Please sign in to comment.