diff --git a/hggit/git_handler.py b/hggit/git_handler.py
index 8dd49f530b020669eb3d44fb2d1b6c31ce0defd4_aGdnaXQvZ2l0X2hhbmRsZXIucHk=..ce3c2d71d9db26bfe5f5e12d2e9135ebaf609fc0_aGdnaXQvZ2l0X2hhbmRsZXIucHk= 100644
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -1655,7 +1655,7 @@
         # text is not valid utf-8, try to make sense of it
         if encoding:
             try:
-                return string.decode(encoding).encode('utf-8')
+                return string.decode(pycompat.sysstr(encoding)).encode('utf-8')
             except UnicodeDecodeError:
                 pass