A few more fixes for the str -> bytes conversion.
authorW. Trevor King <wking@tremily.us>
Sat, 21 Apr 2012 16:33:31 +0000 (12:33 -0400)
committerW. Trevor King <wking@tremily.us>
Sat, 21 Apr 2012 16:33:31 +0000 (12:33 -0400)
pyassuan/client.py
pyassuan/server.py

index c9d1357134d5512d79df09b68d3547a7b6d33245..2feca475ce9121a7ac0f219542ad93b1e2e643c1 100644 (file)
@@ -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:
index 02629063fd1e488e580ae3e2fdf8ac38b8fc8161..1318a2b465c0f10b4b51dcefe2a0af0688b1d731 100644 (file)
@@ -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)