From aa91316c268ecc00eb1217e9d2903cb52b675fe7 Mon Sep 17 00:00:00 2001 From: Nikki Heald Date: Wed, 1 Apr 2015 16:18:02 +0100 Subject: 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 --- pygerrit/ssh.py | 6 ++++++ 1 file changed, 6 insertions(+) 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, -- cgit v1.2.1