From: W. Trevor King Date: Sat, 21 Apr 2012 16:33:31 +0000 (-0400) Subject: A few more fixes for the str -> bytes conversion. X-Git-Tag: v0.2~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4c6abd251db99612d8e6591ec514f4a6070e67d6;p=pyassuan.git A few more fixes for the str -> bytes conversion. --- diff --git a/pyassuan/client.py b/pyassuan/client.py index c9d1357..2feca47 100644 --- a/pyassuan/client.py +++ b/pyassuan/client.py @@ -40,10 +40,10 @@ class AssuanClient (object): def connect(self): if not self.input: self.logger.info('read from stdin') - self.input = _sys.stdin + self.input = _sys.stdin.buffer if not self.output: self.logger.info('write to stdout') - self.output = _sys.stdout + self.output = _sys.stdout.buffer def disconnect(self): if self.close_on_disconnect: diff --git a/pyassuan/server.py b/pyassuan/server.py index 0262906..1318a2b 100644 --- a/pyassuan/server.py +++ b/pyassuan/server.py @@ -74,10 +74,10 @@ class AssuanServer (object): def connect(self): if not self.input: self.logger.info('read from stdin') - self.input = _sys.stdin + self.input = _sys.stdin.buffer if not self.output: self.logger.info('write to stdout') - self.output = _sys.stdout + self.output = _sys.stdout.buffer def disconnect(self): if self.close_on_disconnect: @@ -139,7 +139,7 @@ class AssuanServer (object): rstring = str(response) self.logger.info('S: {}'.format(response)) self.output.write(bytes(response)) - self.output.write('\n') + self.output.write(b'\n') try: self.output.flush() except IOError: @@ -291,8 +291,8 @@ class AssuanSocketServer (object): def spawn_thread(self, name, socket, address): server = self.server(name=name, **self.kwargs) - server.input = socket.makefile('r') - server.output = socket.makefile('w') + server.input = socket.makefile('rb') + server.output = socket.makefile('wb') thread = _threading.Thread(target=server.run, name=name) thread.start() self.threads.append(thread)