Unix: fix fortune on Python 3

Closes #888
This commit is contained in:
spline 2014-10-22 17:47:39 +03:00 committed by Mikaela Suomalainen
parent fcbf9e0ae5
commit 06b5e04b0b

View File

@ -221,6 +221,10 @@ class Unix(callbacks.Plugin):
'not available.'), Raise=True) 'not available.'), Raise=True)
(out, err) = inst.communicate() (out, err) = inst.communicate()
inst.wait() inst.wait()
if sys.version_info[0] > 2:
lines = [i.decode('utf-8').rstrip() for i in out.splitlines()]
lines = list(map(str, lines))
else:
lines = out.splitlines() lines = out.splitlines()
lines = list(map(str.rstrip, lines)) lines = list(map(str.rstrip, lines))
lines = filter(None, lines) lines = filter(None, lines)