deal with encoding issues in python3

when we encode explicitly, we return bytes, so open files as binary
This commit is contained in:
Antoine Beaupré 2017-07-15 16:21:41 -04:00
parent f667428758
commit 0bcd16f1ab
No known key found for this signature in database
GPG key ID: 792152527B75921E

View file

@ -726,7 +726,7 @@ class LyricsPlugin(plugins.BeetsPlugin):
if self.rst is not None:
slug = re.sub(r'\W+', '-', unidecode(self.artist).lower())
path = os.path.join(directory, 'artists', slug + u'.rst')
with open(path, 'w') as output:
with open(path, 'wb') as output:
output.write(self.rst.encode('utf-8'))
self.rst = None
if item is None:
@ -761,7 +761,7 @@ class LyricsPlugin(plugins.BeetsPlugin):
raise
indexfile = os.path.join(directory, 'index.rst')
if not os.path.exists(indexfile):
with open(indexfile, 'w') as output:
with open(indexfile, 'wb') as output:
output.write(u'''Lyrics
======
@ -778,7 +778,7 @@ Artist index:
''')
conffile = os.path.join(directory, 'conf.py')
if not os.path.exists(conffile):
with open(conffile, 'w') as output:
with open(conffile, 'wb') as output:
output.write(u'''# -*- coding: utf-8 -*-
master_doc = 'index'
project = u'Lyrics'