Skip to content

Commit 0148070

Browse files
authored
Merge pull request #2566 from beetbox/yaml-encoding
Load YAML as binary data
2 parents 9840964 + 35dd6fd commit 0148070

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

beets/util/confit.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ def load_yaml(filename):
668668
parsed, a ConfigReadError is raised.
669669
"""
670670
try:
671-
with open(filename, 'r') as f:
671+
with open(filename, 'rb') as f:
672672
return yaml.load(f, Loader=Loader)
673673
except (IOError, yaml.error.YAMLError) as exc:
674674
raise ConfigReadError(filename, exc)
@@ -908,9 +908,10 @@ def dump(self, full=True, redact=False):
908908
default_source = source
909909
break
910910
if default_source and default_source.filename:
911-
with open(default_source.filename, 'r') as fp:
911+
with open(default_source.filename, 'rb') as fp:
912912
default_data = fp.read()
913-
yaml_out = restore_yaml_comments(yaml_out, default_data)
913+
yaml_out = restore_yaml_comments(yaml_out,
914+
default_data.decode('utf8'))
914915

915916
return yaml_out
916917

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ Fixes:
107107
* :doc:`/plugins/web`: Avoid a crash when sending binary data, such as
108108
Chromaprint fingerprints, in music attributes. :bug:`2542` :bug:`2532`
109109
* Fix a hang when parsing templates that end in newlines. :bug:`2562`
110+
* Fix a crash when reading non-ASCII characters in configuration files on
111+
Windows under Python 3. :bug:`2456` :bug:`2565` :bug:`2566`
110112

111113
Two plugins had backends removed due to bitrot:
112114

0 commit comments

Comments
 (0)