mirror of
https://github.com/beetbox/beets.git
synced 2025-12-15 21:14:19 +01:00
Convert YAML keys and values back to strings
I hadn't quite realized before that the user could also change the *keys* to be non-strings too! This also prevents against that by just reinterpreting everything as strings.
This commit is contained in:
parent
0873d31419
commit
0e20770cc3
1 changed files with 8 additions and 2 deletions
|
|
@ -52,7 +52,8 @@ def dump(arg):
|
|||
|
||||
|
||||
def load(s):
|
||||
"""Read a sequence of YAML documents back to a list of dictionaries.
|
||||
"""Read a sequence of YAML documents back to a list of dictionaries
|
||||
with string keys and values.
|
||||
|
||||
Can raise a `ParseError`.
|
||||
"""
|
||||
|
|
@ -65,7 +66,12 @@ def load(s):
|
|||
type(d).__name__
|
||||
)
|
||||
)
|
||||
out.append(d)
|
||||
|
||||
# Convert all keys and values to strings. They started out
|
||||
# as strings, but the user may have inadvertently messed
|
||||
# this up.
|
||||
out.append({unicode(k): unicode(v) for k, v in d.items()})
|
||||
|
||||
except yaml.YAMLError as e:
|
||||
raise ParseError('invalid YAML: {}'.format(e))
|
||||
return out
|
||||
|
|
|
|||
Loading…
Reference in a new issue