mirror of
https://github.com/beetbox/beets.git
synced 2025-12-31 04:52:49 +01:00
Load YAML as binary data
This lets the YAML library itself deal with the encoding (mostly), which should address #2456 and #2565, which have to do with `open` giving us a system-specific encoding by default on Python 3 on Windows when the files should have been written using UTF-8 per the YAML standard.
This commit is contained in:
parent
9840964f51
commit
060041a69e
1 changed files with 4 additions and 3 deletions
|
|
@ -668,7 +668,7 @@ def load_yaml(filename):
|
|||
parsed, a ConfigReadError is raised.
|
||||
"""
|
||||
try:
|
||||
with open(filename, 'r') as f:
|
||||
with open(filename, 'rb') as f:
|
||||
return yaml.load(f, Loader=Loader)
|
||||
except (IOError, yaml.error.YAMLError) as exc:
|
||||
raise ConfigReadError(filename, exc)
|
||||
|
|
@ -908,9 +908,10 @@ class Configuration(RootView):
|
|||
default_source = source
|
||||
break
|
||||
if default_source and default_source.filename:
|
||||
with open(default_source.filename, 'r') as fp:
|
||||
with open(default_source.filename, 'rb') as fp:
|
||||
default_data = fp.read()
|
||||
yaml_out = restore_yaml_comments(yaml_out, default_data)
|
||||
yaml_out = restore_yaml_comments(yaml_out,
|
||||
default_data.decode('utf8'))
|
||||
|
||||
return yaml_out
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue