Hi, This appears to be an 'apertium-dbus' bug (not 'apertium-tolk'). It seems the code in 'src/command_line.py' used the deprecated 'os.popen3' function and did not encode the input to UTF-8 before attempting to send it over (nor did it decode the output). Switching to 'subprocess.Popen' and adding the required encode/decode UTF-8 calls appears to have fixed this bug.
Patch attached.
--- apertium-dbus-0.1/src/command_line.py 2008-01-19 12:57:10.000000000 -0500 +++ apertium-dbus-0.1/src/command_line_modified.py 2014-03-30 03:59:34.822066803 -0400 @@ -1,6 +1,6 @@ def call(cmdline, _in): - import os - + import subprocess + """A convenience function to invoke a subprocess with the parameter list name (where the first argument is the name of an executable). The subprocess is fed the contents of @@ -8,17 +8,16 @@ stderr from the subprocess. If stderr is not empty, we raise an exception, otherwise we return the contents of stdout.""" - child_in, child_out, child_err = os.popen3(" ".join(cmdline)) - - child_in.write(_in) - child_in.close() # You MUST close the child's stdin to get output from some programs - - out = child_out.read() - child_out.close() - err = child_err.read() - child_err.close() - - return out, err + proc = subprocess.Popen(cmdline, + stdin =subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + proc.stdin.write(_in.encode('utf-8')) + proc.stdin.close() + proc.stdin = None + out, err = proc.communicate() + + return out.decode('utf-8'), err.decode('utf-8') class OsCommand(object): def __init__(self, cmd):
signature.asc
Description: OpenPGP digital signature