Skip to content

Commit b832b5d

Browse files
authored
maybe_string dealing with non-unicode strings
1 parent 8f3dec8 commit b832b5d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pygit2/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ def maybe_string(ptr):
3434
if not ptr:
3535
return None
3636

37-
return ffi.string(ptr).decode('utf8')
38-
37+
try:
38+
return ffi.string(ptr).decode('utf8')
39+
except UnicodeDecodeError:
40+
return ffi.string(ptr)
3941

4042
def to_bytes(s, encoding='utf-8', errors='strict'):
4143
if s == ffi.NULL or s is None:

0 commit comments

Comments
 (0)