Skip to content

Commit

Permalink
Merge c32cdbd into 7f34427
Browse files Browse the repository at this point in the history
  • Loading branch information
scorphus committed Aug 2, 2021
2 parents 7f34427 + c32cdbd commit 66a7584
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/output_readers/test_rerun.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ def test_get_output_invalid_continuation_byte(self, popen_mock):
actual = rerun.get_output('', '')
assert actual == expected

def test_get_output_unicode_misspell(self, mocker):
wait_output_spier = mocker.spy(rerun, '_wait_output')
rerun.get_output(u'pácman', u'pácman')
wait_output_spier.assert_called_once()

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
3 changes: 3 additions & 0 deletions thefuck/output_readers/read_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def _group_by_calls(log):


def _get_script_group_lines(grouped, script):
if six.PY2:
script = script.encode('utf-8', errors='replace')

parts = shlex.split(script)

for script_line, lines in reversed(grouped):
Expand Down
4 changes: 4 additions & 0 deletions thefuck/output_readers/rerun.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import shlex
import six
from subprocess import Popen, PIPE, STDOUT
from psutil import AccessDenied, Process, TimeoutExpired
from .. import logs
Expand Down Expand Up @@ -53,6 +54,9 @@ def get_output(script, expanded):
env = dict(os.environ)
env.update(settings.env)

if six.PY2:
expanded = expanded.encode('utf-8', errors='replace')

split_expand = shlex.split(expanded)
is_slow = split_expand[0] in settings.slow_commands if split_expand else False
with logs.debug_time(u'Call: {}; with env: {}; is slow: {}'.format(
Expand Down

0 comments on commit 66a7584

Please sign in to comment.