From 4c6abd251db99612d8e6591ec514f4a6070e67d6 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 21 Apr 2012 12:33:31 -0400 Subject: [PATCH] A few more fixes for the str -> bytes conversion. --- pyassuan/client.py | 4 ++-- pyassuan/server.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) 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) -- 2.26.2