From 0bcd16f1ab04cd77319ad5f2eb1f44308f674cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Sat, 15 Jul 2017 16:21:41 -0400 Subject: [PATCH] deal with encoding issues in python3 when we encode explicitly, we return bytes, so open files as binary --- beetsplug/lyrics.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index 29bab25a6..c36839b29 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -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'