Skip to content

Commit

Permalink
Support non-english errors with non-ascii chars.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mrh1997 committed Sep 13, 2016
1 parent c57a3ae commit 54e4da8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pygit2/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 54e4da8

Please sign in to comment.