Skip to content

Commit

Permalink
#994: Replace decoding errors with the replacement marker
Browse files Browse the repository at this point in the history
  • Loading branch information
scorphus committed Jul 29, 2021
1 parent eb05b28 commit c2df71c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions tests/output_readers/test_rerun.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ def test_get_output(self, popen_mock, wait_output_mock):
assert rerun.get_output('', '') is None
wait_output_mock.assert_called_once()

@patch('thefuck.output_readers.rerun.Popen')
def test_get_output_invalid_continuation_byte(self, popen_mock):
output = b'ls: illegal option -- \xc3\nusage: ls [-@ABC...] [file ...]\n'
expected = u'ls: illegal option -- \ufffd\nusage: ls [-@ABC...] [file ...]\n'
popen_mock.return_value.stdout.read.return_value = output
actual = rerun.get_output('', '')
assert actual == expected

def test_wait_output_is_slow(self, settings):
assert rerun._wait_output(Mock(), True)
self.proc_mock.wait.assert_called_once_with(settings.wait_slow_command)
Expand Down
2 changes: 1 addition & 1 deletion thefuck/output_readers/rerun.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_output(script, expanded):
result = Popen(expanded, shell=True, stdin=PIPE,
stdout=PIPE, stderr=STDOUT, env=env)
if _wait_output(result, is_slow):
output = result.stdout.read().decode('utf-8')
output = result.stdout.read().decode('utf-8', errors='replace')
logs.debug(u'Received output: {}'.format(output))
return output
else:
Expand Down

0 comments on commit c2df71c

Please sign in to comment.