diff options
author | Nikki Heald <nicky@notnowlewis.com> | 2015-04-01 16:18:02 +0100 |
---|---|---|
committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2015-04-06 13:44:46 +0900 |
commit | aa91316c268ecc00eb1217e9d2903cb52b675fe7 (patch) | |
tree | c4e620a0668ebaeb51cc562c19023f2328de94e4 | |
parent | daad8e23d9bbcd8a2bc565497be50a3cc29dae6b (diff) | |
download | pygerrit-aa91316c268ecc00eb1217e9d2903cb52b675fe7.tar.gz |
Allow unicode characters in gerrit commands
Trying to use pygerrit to submit reviews fails if there
is a unicode character in the review comment. This change
sees if the message is valid ascii, and if it's not,
encodes as utf-8.
Change-Id: Ia14d59d28b11a78bee9d89fd84fb09976015787f
-rw-r--r-- | pygerrit/ssh.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/pygerrit/ssh.py b/pygerrit/ssh.py index 2955094..350eb48 100644 --- a/pygerrit/ssh.py +++ b/pygerrit/ssh.py @@ -171,6 +171,12 @@ class GerritSSHClient(SSHClient): raise ValueError("command must be a string") gerrit_command = "gerrit " + command + # are we sending non-ascii data? + try: + gerrit_command.encode('ascii') + except UnicodeEncodeError: + gerrit_command = gerrit_command.encode('utf-8') + self._connect() try: stdin, stdout, stderr = self.exec_command(gerrit_command, |