Permalink
Browse files

accept unicode strings in Connection.write, and do the obvious thing …

…with them
  • Loading branch information...
sah committed Feb 2, 2012
1 parent c60109e commit e9321d83bedeaa3dce09a111d85d0e35576e6981
Showing with 3 additions and 0 deletions.
  1. +3 −0 monocle/stack/network/__init__.py
@@ -36,6 +36,7 @@ def __init__(self, stack_conn=None):
self._stack_conn = stack_conn
self.writing = False
self._flush_cb = Callback()
+ self.write_encoding = 'utf-8'
@_o
def read_some(self):
@@ -78,6 +79,8 @@ def readline(self):
return self.read_until("\n")
def write(self, data):
+ if isinstance(data, unicode):
+ data = data.encode(self.write_encoding)
self._check_closed()
self.writing = True
self._stack_conn.write(data)

0 comments on commit e9321d8

Please sign in to comment.