diff --git a/beetsplug/convert.py b/beetsplug/convert.py index e08e473f0..8858d710c 100644 --- a/beetsplug/convert.py +++ b/beetsplug/convert.py @@ -169,7 +169,12 @@ class ConvertPlugin(BeetsPlugin): Raises `subprocess.CalledProcessError` if the command exited with a non-zero status code. """ - quiet = self.config['quiet'].get() + # The paths and arguments must be bytes. + assert isinstance(command, bytes) + assert isinstance(source, bytes) + assert isinstance(dest, bytes) + + quiet = self.config['quiet'].get(bool) if not quiet and not pretend: self._log.info(u'Encoding {0}', util.displayable_path(source)) @@ -178,8 +183,8 @@ class ConvertPlugin(BeetsPlugin): args = shlex.split(command) for i, arg in enumerate(args): args[i] = Template(arg).safe_substitute({ - 'source': source.decode('utf8'), - 'dest': dest.decode('utf8'), + b'source': source, + b'dest': dest, }) if pretend: @@ -391,6 +396,7 @@ class ConvertPlugin(BeetsPlugin): command, ext = get_format() tmpdir = self.config['tmpdir'].get() fd, dest = tempfile.mkstemp('.' + ext, dir=tmpdir) + dest = util.bytestring_path(dest) os.close(fd) _temp_files.append(dest) # Delete the transcode later. try: diff --git a/test/test_convert.py b/test/test_convert.py index 3fec8879e..034d8a465 100644 --- a/test/test_convert.py +++ b/test/test_convert.py @@ -23,6 +23,7 @@ from test import helper from test.helper import control_stdin from beets.mediafile import MediaFile +from beets import util class TestHelper(helper.TestHelper): @@ -105,7 +106,9 @@ class ConvertCliTest(unittest.TestCase, TestHelper): self.item = self.album.items()[0] self.load_plugins('convert') - self.convert_dest = os.path.join(self.temp_dir, 'convert_dest') + self.convert_dest = util.bytestring_path( + os.path.join(self.temp_dir, 'convert_dest') + ) self.config['convert'] = { 'dest': self.convert_dest, 'paths': {'default': 'converted'},