Merge pull request #264 from starcraftman/fix_codec

Close #262 UnicodeDecodeError
This commit is contained in:
Junegunn Choi 2015-07-31 03:26:17 +09:00
commit a6f3a020e3

View File

@ -1192,7 +1192,7 @@ class Command(object):
raise CmdTimedOut(['Timeout!'])
tfile.seek(0)
result = [line.decode().rstrip() for line in tfile]
result = [line.decode('utf-8', 'replace').rstrip() for line in tfile]
if proc.returncode != 0:
msg = ['']
@ -1344,7 +1344,7 @@ def esc(name):
def nonblock_read(fname):
""" Read a file with nonblock flag. Return the last line. """
fread = os.open(fname, os.O_RDONLY | os.O_NONBLOCK)
buf = os.read(fread, 100000).decode()
buf = os.read(fread, 100000).decode('utf-8', 'replace')
os.close(fread)
line = buf.rstrip('\r\n')