summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikki Heald <nicky@notnowlewis.com>2015-04-01 16:18:02 +0100
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2015-04-06 13:44:46 +0900
commitaa91316c268ecc00eb1217e9d2903cb52b675fe7 (patch)
treec4e620a0668ebaeb51cc562c19023f2328de94e4
parentdaad8e23d9bbcd8a2bc565497be50a3cc29dae6b (diff)
downloadpygerrit-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.py6
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,