From e6a1f5a3dc1657631c368be1c9b3f439b5e37e2a Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Thu, 19 Aug 2021 17:24:01 -0400 Subject: [PATCH] convert: Split command in `str` form ...with yet another round-trip conversion. :/ --- beetsplug/convert.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/beetsplug/convert.py b/beetsplug/convert.py index 36cfd0ee9..2ce68b2cd 100644 --- a/beetsplug/convert.py +++ b/beetsplug/convert.py @@ -206,8 +206,15 @@ class ConvertPlugin(BeetsPlugin): source = decode_commandline_path(source) dest = decode_commandline_path(dest) + # Split the command using shell syntax. We need to pass the + # string through a `str` because, at least on some Python + # versions, shlex.split does not support bytes. + args = [ + a.encode('utf8', 'surrogateescape') + for a in shlex.split(command.decode('utf8', 'surrogateescape')) + ] + # Substitute $source and $dest in the argument list. - args = shlex.split(command) encode_cmd = [] for i, arg in enumerate(args): args[i] = Template(arg).safe_substitute({