Matthieu Baerts dc71ef7553 Python2: fixed UnicodeEncodeError
git-review crashes when using it with Python 2 (the default one in
Ubuntu 14.04): https://bugs.launchpad.net/git-review/+bug/1308050

It seems that in the main() method, 'cmd' can contain utf-8 chars:
git-review find '(détachée' (french word for 'detached') as topic.
This utf-8 string has caused a crash.
I guess we should always have an utf-8 string from a git command
but because I'm not so sure about that and I let you review this :-)

As advised by Clark Boylan, it can be interesting to encode the string
in run_command_status() method.
It's just needed to 'encode' it when we have an unicode string (python
2). shlex.split needs a 'str', not an 'unicode' type with utf-8 chars,
not a 'bytes' type and not not a 'bytes' type converted to 'str' (with
Python 3):

>>> shlex.split(str("echo héhé".encode('utf-8')))
['becho h\\xc3\\xa9h\\xc3\\xa9']

PS: Fixed error when launching tests with Python 2.6
PS2: Used 'sys.version_info' instead of 'sys.version'
     (thanks to Alex Gaynor)

Change-Id: Ie5bed46e562d3f9f2df54abe8b0fd6e849583df7
2014-04-24 01:42:19 +02:00
..
2013-08-15 20:42:37 +00:00
2014-04-24 01:42:19 +02:00