mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-21 20:38:54 +00:00
python2.7 unicode error
This commit is contained in:
parent
1bb04b41eb
commit
ae2949cfa2
@ -11,6 +11,7 @@ import io
|
|||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
import six
|
import six
|
||||||
|
import sys
|
||||||
from .utils import DEVNULL, memoize, cache
|
from .utils import DEVNULL, memoize, cache
|
||||||
|
|
||||||
|
|
||||||
@ -50,7 +51,10 @@ class Generic(object):
|
|||||||
history_file_name = self._get_history_file_name()
|
history_file_name = self._get_history_file_name()
|
||||||
if os.path.isfile(history_file_name):
|
if os.path.isfile(history_file_name):
|
||||||
with open(history_file_name, 'a') as history:
|
with open(history_file_name, 'a') as history:
|
||||||
history.write(self._get_history_line(command_script))
|
if sys.version_info >= (3, 0):
|
||||||
|
history.write(self._get_history_line(command_script))
|
||||||
|
else:
|
||||||
|
history.write(self._get_history_line(command_script).encode("utf-8"))
|
||||||
|
|
||||||
def _script_from_history(self, line):
|
def _script_from_history(self, line):
|
||||||
"""Returns prepared history line.
|
"""Returns prepared history line.
|
||||||
@ -80,7 +84,10 @@ class Generic(object):
|
|||||||
|
|
||||||
def split_command(self, command):
|
def split_command(self, command):
|
||||||
"""Split the command using shell-like syntax."""
|
"""Split the command using shell-like syntax."""
|
||||||
return shlex.split(command)
|
if sys.version_info >= (3, 0):
|
||||||
|
return shlex.split(command)
|
||||||
|
else:
|
||||||
|
return shlex.split(command.encode("utf-8"))
|
||||||
|
|
||||||
def quote(self, s):
|
def quote(self, s):
|
||||||
"""Return a shell-escaped version of the string s."""
|
"""Return a shell-escaped version of the string s."""
|
||||||
|
@ -31,7 +31,7 @@ class Command(object):
|
|||||||
try:
|
try:
|
||||||
self._script_parts = shells.split_command(self.script)
|
self._script_parts = shells.split_command(self.script)
|
||||||
except Exception:
|
except Exception:
|
||||||
logs.debug("Can't split command script {} because:\n {}".format(
|
logs.debug(u"Can't split command script {} because:\n {}".format(
|
||||||
self, sys.exc_info()))
|
self, sys.exc_info()))
|
||||||
self._script_parts = None
|
self._script_parts = None
|
||||||
return self._script_parts
|
return self._script_parts
|
||||||
@ -44,7 +44,7 @@ class Command(object):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'Command(script={}, stdout={}, stderr={})'.format(
|
return u'Command(script={}, stdout={}, stderr={})'.format(
|
||||||
self.script, self.stdout, self.stderr)
|
self.script, self.stdout, self.stderr)
|
||||||
|
|
||||||
def update(self, **kwargs):
|
def update(self, **kwargs):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user