Source

crossroads / crossroads / message.py

Diff from to

crossroads/message.py

 
 from ctypes import sizeof, string_at, c_ubyte, byref, c_size_t, c_char, c_int
 
-from stuf.six import PY3, tobytes, tounicode, u, b, isunicode
+from stuf.six import PY3, tobytes, tounicode, u, isunicode, byteme
 
 from . import lowest as xs
 from .constants import MORE
 
     def __bytes__(self):
         if self.msg is None:
-            return b('')
+            return b''
         return tobytes(string_at(byref(self.msg), self.size))
 
     def __unicode__(self):
     def __init__(self, size, source):
         super(SendMsg, self).__init__()
         if isinstance(source, Msg):
-            self.msg = source = bytes(source)
+            self.msg = source = byteme(source)
         elif isunicode(source):
-            self.msg = source = b(source)
+            self.msg = source = tobytes(source)
         else:
             self.msg = source
         self.size = len(source) if size is None else size
 
 
+SLOTS2 = 'msg rc more last_rc'.split()
+
 class MsgXS(Msg):
 
     def close(self):
 
 class RecvMsg32(MsgXS):
 
-    __slots__ = SLOTS
+    __slots__ = SLOTS2
 
     def __init__(self):
         super(RecvMsg32, self).__init__()
 
 class SendMsg32(MsgXS):
 
-    __slots__ = SLOTS
+    __slots__ = SLOTS2
 
     def __init__(self, source):
         super(SendMsg32, self).__init__()
             self.msg = source.msg
         else:
             self.msg = xs.msg_t()
-            source = b(source)
+            source = tobytes(source)
             length = len(source)
             self.rc = xs.msg_init_size(self.msg, length)
             xs.memmove(xs.msg_data(self.msg), source, length)