1
0
Fork 0

site: Specify UTF-8 encoding for songquotes

In some cases, the default codec used by PyYAML is not UTF-8, so loading
the song quotes database fails. Using the `codecs.open` helper function
ensures that the contents of the file are always read with the correct
character set.
master
Dustin 2018-07-26 18:19:52 -05:00
parent b64db4092a
commit 190c63c594
1 changed files with 3 additions and 1 deletions

View File

@ -1,5 +1,6 @@
from milla.dispatch import routing
from webob import acceptparse
import codecs
import jinja2
import milla
import os
@ -24,7 +25,8 @@ env = jinja2.Environment(
)
with open(os.path.join(os.path.dirname(__file__), 'songquotes.yml')) as f:
songquotes = os.path.join(os.path.dirname(__file__), 'songquotes.yml')
with codecs.open(songquotes, 'r', encoding='utf-8') as f:
songquotes = yaml.load(f, Loader=YamlLoader)