From 605a9a487bba6e25fb48d4e3076c89b7f686517a Mon Sep 17 00:00:00 2001 From: chenguodong Date: Mon, 22 Aug 2011 18:42:47 +0800 Subject: [PATCH] Fixed UnicodeDecodeError while uploading changes. When commit with comment that has non-ASCII characters, UnicodeDecodeError will be raised while uploading multiple project/branch changes. Because some strings in script are not str type, but unicode. So all the strings are decoded to unicode, and python use ascii to do this, it can not decode non-ASCII characters, so UnicodeDecodeError raised. Signed-off-by: chenguodong Change-Id: I46447f489a4b9760a5899c7ba9d764b688594e46 --- subcmds/upload.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/subcmds/upload.py b/subcmds/upload.py index c1958373..a08926c6 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py @@ -215,6 +215,11 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ branches[project.name] = b script.append('') + script = [ x.encode('utf-8') + if issubclass(type(x), unicode) + else x + for x in script ] + script = Editor.EditString("\n".join(script)).split("\n") project_re = re.compile(r'^#?\s*project\s*([^\s]+)/:$')