Support non-english errors with non-ascii chars.

Libgit2 partially forwards OS error message texts.
On non-english Windows OSes these errors may contain non-ascii characters (i.e. umlauts).
To avoid that a UnicodeDecodeError is raised the error message is interpreted as UTF-8.
The solution should not be necessary on linux/osx as they return always ascii (as far as I know).
Thus this solution will not change the behaviour on linux/osx.
This commit is contained in:
mrh1997 2016-09-13 22:31:49 +02:00 committed by GitHub
parent c57a3aeb22
commit 54e4da837b

View File

@ -40,7 +40,7 @@ def check_error(err, io=False):
# Error message
giterr = C.giterr_last()
if giterr != ffi.NULL:
message = ffi.string(giterr.message).decode()
message = ffi.string(giterr.message).decode('utf8')
else:
message = "err %d (no message provided)" % err