> def toggletrace(cmd): > - quoted = shellquote(cmd.strip()).replace(b'\\', b'\\\\') > + cmd = cmd.decode('ascii') > + quoted = shellquote(cmd.strip()).encode('ascii') > + quoted = quoted.replace(b'\\', b'\\\\') Perhaps _bytespath/_strpath can be used to avoid possible side effect on Python 2.