'Handle a call to GPG - pass input data, collect output data'

def _handle_io(self, args, file, result, passphrase=None, binary=False):

    p = self._open_subprocess(args, (passphrase is not None))
    if (not binary):
        stdin = codecs.getwriter(self.encoding)(p.stdin)
    else:
        stdin = p.stdin
    if passphrase:
        _write_passphrase(stdin, passphrase, self.encoding)
    writer = _threaded_copy_data(file, stdin)
    self._collect_output(p, result, writer, stdin)
    return result
