Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repo.git.log() raises ''utf8' codec can't decode byte x in position y: invalid start byte #483

Closed
iganchevup8 opened this issue Jul 1, 2016 · 2 comments

Comments

@iganchevup8
Copy link

iganchevup8 commented Jul 1, 2016

I am recovering the logs of a repository with repo.git.log() and run into decoding charset error. Trace follows:

---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
<ipython-input-34-7aab8d0e3a89> in <module>()
----> 1 git.log()

/usr/local/lib/python2.7/dist-packages/git/cmd.pyc in <lambda>(*args, **kwargs)
    448         if name[0] == '_':
    449             return LazyMixin.__getattr__(self, name)
--> 450         return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
    451 
    452     def _set_cache_(self, attr):

/usr/local/lib/python2.7/dist-packages/git/cmd.pyc in _call_process(self, method, *args, **kwargs)
    900             # END provide better error message
    901         else:
--> 902             return self.execute(make_call(), **_kwargs)
    903         # END handle windows default installation
    904 

/usr/local/lib/python2.7/dist-packages/git/cmd.pyc in execute(self, command, istream, with_keep_cwd, with_extended_output, with_exceptions, as_process, output_stream, stdout_as_string, kill_after_timeout, with_stdout, **subprocess_kwargs)
    696 
    697         if isinstance(stdout_value, bytes) and stdout_as_string:  # could also be output_stream
--> 698             stdout_value = stdout_value.decode(defenc)
    699 
    700         # Allow access to the command's status code

/usr/lib/python2.7/encodings/utf_8.pyc in decode(input, errors)
     14 
     15 def decode(input, errors='strict'):
---> 16     return codecs.utf_8_decode(input, errors, True)
     17 
     18 class IncrementalEncoder(codecs.IncrementalEncoder):

UnicodeDecodeError: 'utf8' codec can't decode byte 0xb4 in position 25865158: invalid start byte

Adding .decode(defenc, 'ignore') doesn't solve the issue.

Any ideas about how to solve that?

Thanks

@iganchevup8
Copy link
Author

iganchevup8 commented Jul 5, 2016

After upgrading GitPython the issue remains. Trace follows:

---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
<ipython-input-81-7aab8d0e3a89> in <module>()
----> 1 git.log()

/usr/local/lib/python2.7/dist-packages/git/cmd.pyc in <lambda>(*args, **kwargs)
    448         self._git_options = ()
    449 
--> 450         # Extra environment variables to pass to git commands
    451         self._environment = {}
    452 

/usr/local/lib/python2.7/dist-packages/git/cmd.pyc in _call_process(self, method, *args, **kwargs)
    900         # END utility to recreate call after changes
    901 
--> 902         if sys.platform == 'win32':
    903             try:
    904                 try:

/usr/local/lib/python2.7/dist-packages/git/cmd.pyc in execute(self, command, istream, with_keep_cwd, with_extended_output, with_exceptions, as_process, output_stream, stdout_as_string, kill_after_timeout, with_stdout, **subprocess_kwargs)
    696             def as_text(stdout_value):
    697                 return not output_stream and safe_decode(stdout_value) or '<OUTPUT_STREAM>'
--> 698             # end
    699 
    700             if stderr_value:

/usr/lib/python2.7/encodings/utf_8.pyc in decode(input, errors)
     14 
     15 def decode(input, errors='strict'):
---> 16     return codecs.utf_8_decode(input, errors, True)
     17 
     18 class IncrementalEncoder(codecs.IncrementalEncoder):

UnicodeDecodeError: 'utf8' codec can't decode byte 0xb4 in position 25865158: invalid start byte

Need to be said I think that I'm having this issue with IPython.
Any advices about how to solve that, please?

@iganchevup8
Copy link
Author

It was a locale issue. After installing en_US.UTF-8 as a default locale, everything works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant