Skip to content

Commit

Permalink
git: handle encoding errors
Browse files Browse the repository at this point in the history
Use the replacement error handling to avoid UnicodeDecodeErrors like
this:

An internal Exception has occured. This should not have happenend.
Please open an issue at https://github.com/BobBuildTool/bob with the following backtrace:
Bob version 0.20.1.dev12+g71b3cba
Traceback (most recent call last):
  File "bob/pym/bob/scripts.py", line 153, in catchErrors
    ret = fun(*args, **kwargs)
  File "bob/pym/bob/scripts.py", line 254, in cmd
    ret = cmd(args.args, bobRoot)
  File "bob/pym/bob/scripts.py", line 74, in __status
    doStatus(*args, **kwars)
  File "bob/pym/bob/cmds/build/status.py", line 300, in doStatus
    printer.showAllDirs(args.attic)
  File "bob/pym/bob/cmds/build/status.py", line 218, in showAllDirs
    status = getScm(scmSpec).status(workspace)
  File "bob/pym/bob/scm/git.py", line 689, in status
    *what)
  File "bob/pym/bob/scm/git.py", line 619, in callGit
    universal_newlines=True, stderr=subprocess.DEVNULL)
  File "/usr/lib/python3.7/subprocess.py", line 395, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.7/subprocess.py", line 474, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
  File "/usr/lib/python3.7/subprocess.py", line 926, in communicate
    stdout = self.stdout.read()
  File "/usr/lib/python3.7/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe5 in position 553069: invalid continuation byte
  • Loading branch information
rhubert authored and Ralf hubert committed Jun 9, 2022
1 parent 0e9bfbe commit a8af2e3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pym/bob/scm/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def callGit(self, workspacePath, *args, check=True):
cwd = os.path.join(workspacePath, self.__dir)
try:
output = subprocess.check_output(cmdLine, cwd=cwd,
universal_newlines=True, stderr=subprocess.DEVNULL)
universal_newlines=True, stderr=subprocess.DEVNULL, errors='replace')
except subprocess.CalledProcessError as e:
if check:
raise BuildError("git error:\n Directory: '{}'\n Command: '{}'\n'{}'".format(
Expand Down

0 comments on commit a8af2e3

Please sign in to comment.