From 0f88fb96869b6ac3ed4dac7d23310a9327d3c89c Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 15 Oct 2010 11:56:28 +0200 Subject: Added test to verify the actor type can handle and parse unicode if it is passed in test_odb: added more information to the message output --- lib/git/ext/gitdb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/git/ext/gitdb b/lib/git/ext/gitdb index 425ecf04..78665b13 160000 --- a/lib/git/ext/gitdb +++ b/lib/git/ext/gitdb @@ -1 +1 @@ -Subproject commit 425ecf04aa5038c3d46b01ca20de17c51ef6c4e5 +Subproject commit 78665b13ff4125f4ce3e5311d040c027bdc92a9a -- cgit v1.2.3 From 0019d7dc8c72839d238065473a62b137c3c350f5 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 15 Oct 2010 12:34:43 +0200 Subject: Added unicode handling for author names. They will now be properly encoded into the byte stream, as well as decoded from it --- lib/git/objects/commit.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/git/objects/commit.py b/lib/git/objects/commit.py index f3a6e216..c7da01e8 100644 --- a/lib/git/objects/commit.py +++ b/lib/git/objects/commit.py @@ -368,9 +368,14 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): write("parent %s\n" % p) a = self.author + aname = a.name + if isinstance(aname, unicode): + aname = aname.encode(self.encoding) + # END handle unicode in name + c = self.committer fmt = "%s %s <%s> %s %s\n" - write(fmt % ("author", a.name, a.email, + write(fmt % ("author", aname, a.email, self.authored_date, altz_to_utctz_str(self.author_tz_offset))) @@ -425,12 +430,19 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable): readline() # END handle encoding + # decode the authors name + try: + self.author.name = self.author.name.decode(self.encoding) + except UnicodeDecodeError: + print >> sys.stderr, "Failed to decode author name: %s" % self.author.name + # END handle author's encoding + # a stream from our data simply gives us the plain message # The end of our message stream is marked with a newline that we strip self.message = stream.read() try: self.message = self.message.decode(self.encoding) - except Exception: + except UnicodeDecodeError: print >> sys.stderr, "Failed to decode message: %s" % self.message # END exception handling return self -- cgit v1.2.3