1
0
mirror of https://github.com/nvbn/thefuck.git synced 2024-10-05 18:31:10 +01:00

#697: Encode expanded script on Python 2

Fix #697
This commit is contained in:
Pablo Santiago Blum de Aguiar 2021-08-01 20:31:10 +02:00 committed by Pablo Aguiar
parent 2a166a7dec
commit 7b7c150bb7
3 changed files with 12 additions and 0 deletions

View File

@ -30,6 +30,11 @@ class TestRerun(object):
actual = rerun.get_output('', '')
assert actual == expected
@patch('thefuck.output_readers.rerun._wait_output')
def test_get_output_unicode_misspell(self, wait_output_mock):
rerun.get_output(u'pácman', u'pácman')
wait_output_mock.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)

View File

@ -40,6 +40,9 @@ def _group_by_calls(log):
def _get_script_group_lines(grouped, script):
if six.PY2:
script = script.encode('utf-8')
parts = shlex.split(script)
for script_line, lines in reversed(grouped):

View File

@ -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
@ -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')
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(