Normalize text and byte type in the ssh plugin helper method that builds up an ssh command (#17860)

Mostly cleanups to make the code more efficient, more pythonic, and obey
the unicode sandwich strategy more but also Fixes #17832
This commit is contained in:
Toshio Kuratomi 2016-10-02 14:55:55 -07:00 committed by GitHub
commit 64c446d9c0
3 changed files with 72 additions and 58 deletions

View file

@ -140,6 +140,7 @@ class ConnectionBase(with_metaclass(ABCMeta, object)):
# ['t\x00\x00\x00', '\x00\x00\x00e\x00\x00\x00']
return [to_text(x.strip()) for x in shlex.split(to_bytes(argstring)) if x.strip()]
except AttributeError:
# In Python3, shlex.split doesn't work on a byte string.
return [to_text(x.strip()) for x in shlex.split(argstring) if x.strip()]
@abstractproperty