Description: Port code to work with Python 3
Author: Martin Pitt <martin.pitt@ubuntu.com>
Forwarded: http://sourceforge.net/p/python-xlib/patches/5/
Updated: 2013-10-11

Index: python-xlib-0.14+20091101/Xlib/protocol/display.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/protocol/display.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/protocol/display.py	2013-10-11 14:19:21.085971348 -0400
@@ -31,8 +31,17 @@
 from Xlib.support import lock, connect
 
 # Xlib.protocol modules
-import rq
-import event
+from Xlib.protocol import rq, event
+
+# in Python 3, bytes are an actual array; in python 2, bytes are still
+# string-like, so in order to get an array element we need to call ord()
+if sys.version[0] >= '3':
+    def _bytes_item(x):
+        return x
+else:
+    def _bytes_item(x):
+        return ord(x)
+
 
 class Display:
     resource_classes = {}
@@ -83,8 +92,8 @@
         # Data used by the send-and-recieve loop
         self.sent_requests = []
         self.request_length = 0
-        self.data_send = ''
-        self.data_recv = ''
+        self.data_send = b''
+        self.data_recv = b''
         self.data_sent_bytes = 0
 
         # Resource ID structures
@@ -227,7 +236,7 @@
         self.resource_id_lock.acquire()
         try:
             i = self.last_resource_id
-            while self.resource_ids.has_key(i):
+            while i in self.resource_ids:
                 i = i + 1
                 if i > self.info.resource_id_mask:
                     i = 0
@@ -503,7 +512,7 @@
 
             # Ignore errors caused by a signal recieved while blocking.
             # All other errors are re-raised.
-            except select.error, err:
+            except select.error as err:
                 if err[0] != errno.EINTR:
                     raise err
 
@@ -518,7 +527,7 @@
             if ws:
                 try:
                     i = self.socket.send(self.data_send)
-                except socket.error, err:
+                except socket.error as err:
                     self.close_internal('server: %s' % err[1])
                     raise self.socket_error
 
@@ -534,7 +543,7 @@
                 if recieving:
                     try:
                         bytes_recv = self.socket.recv(4096)
-                    except socket.error, err:
+                    except socket.error as err:
                         self.close_internal('server: %s' % err[1])
                         raise self.socket_error
 
@@ -640,7 +649,7 @@
                 return gotreq
 
             # Check the first byte to find out what kind of response it is
-            rtype = ord(self.data_recv[0])
+            rtype = _bytes_item(self.data_recv[0])
 
             # Error resposne
             if rtype == 0:
@@ -660,13 +669,13 @@
 
     def parse_error_response(self, request):
         # Code is second byte
-        code = ord(self.data_recv[1])
+        code = _bytes_item(self.data_recv[1])
 
         # Fetch error class
         estruct = self.error_classes.get(code, error.XError)
 
         e = estruct(self, self.data_recv[:32])
-        self.data_recv = buffer(self.data_recv, 32)
+        self.data_recv = self.data_recv[32:]
 
         # print 'recv Error:', e
 
@@ -720,7 +729,7 @@
         req._parse_response(self.data_recv[:self.request_length])
         # print 'recv Request:', req
 
-        self.data_recv = buffer(self.data_recv, self.request_length)
+        self.data_recv = self.data_recv[self.request_length:]
         self.request_length = 0
 
 
@@ -745,7 +754,7 @@
 
         e = estruct(display = self, binarydata = self.data_recv[:32])
 
-        self.data_recv = buffer(self.data_recv, 32)
+        self.data_recv = self.data_recv[32:]
 
         # Drop all requests having an error handler,
         # but which obviously succeded.
@@ -967,7 +976,7 @@
 
 
     def __init__(self, display, *args, **keys):
-        self._binary = apply(self._request.to_binary, args, keys)
+        self._binary = self._request.to_binary(*args, **keys)
         self._data = None
 
         # Don't bother about locking, since no other threads have
Index: python-xlib-0.14+20091101/Xlib/protocol/rq.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/protocol/rq.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/protocol/rq.py	2013-10-11 14:20:03.905972445 -0400
@@ -16,21 +16,31 @@
 #    along with this program; if not, write to the Free Software
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+import types
 
 # Standard modules
 import sys
 import traceback
 import struct
-import string
 from array import array
 import types
-import new
 
 # Xlib modules
 from Xlib import X
 from Xlib.support import lock
 
 
+_PY3 = sys.version[0] >= '3'
+
+# in Python 3, bytes are an actual array; in python 2, bytes are still
+# string-like, so in order to get an array element we need to call ord()
+if _PY3:
+    def _bytes_item(x):
+        return x
+else:
+    def _bytes_item(x):
+        return ord(x)
+
 class BadDataError(Exception): pass
 
 # These are struct codes, we know their byte sizes
@@ -52,10 +62,10 @@
 for c in 'bhil':
     size = array(c).itemsize
 
-    array_unsigned_codes[size] = string.upper(c)
+    array_unsigned_codes[size] = c.upper()
     try:
         struct_to_array_codes[signed_codes[size]] = c
-        struct_to_array_codes[unsigned_codes[size]] = string.upper(c)
+        struct_to_array_codes[unsigned_codes[size]] = c.upper()
     except KeyError:
         pass
 
@@ -135,7 +145,7 @@
 class Pad(Field):
     def __init__(self, size):
         self.size = size
-        self.value = '\0' * size
+        self.value = b'\0' * size
         self.structcode = '%dx' % size
         self.structvalues = 0
 
@@ -190,14 +200,14 @@
     structvalues = 1
 
     def calc_length(self, length):
-        return length / 4
+        return length // 4
 
 class ReplyLength(TotalLengthField):
     structcode = 'L'
     structvalues = 1
 
     def calc_length(self, length):
-        return (length - 32) / 4
+        return (length - 32) // 4
 
 
 class LengthOf(LengthField):
@@ -280,9 +290,9 @@
         self.codes = codes
 
     def check_value(self, value):
-        if type(value) is types.InstanceType:
+        try:
             return getattr(value, self.cast_function)()
-        else:
+        except AttributeError:
             return value
 
     def parse_value(self, value, display):
@@ -380,21 +390,32 @@
     def pack_value(self, val):
         slen = len(val)
 
+        if _PY3 and type(val) is str:
+            val = val.encode('UTF-8')
+
         if self.pad:
-            return val + '\0' * ((4 - slen % 4) % 4), slen, None
+            return val + b'\0' * ((4 - slen % 4) % 4), slen, None
         else:
             return val, slen, None
 
     def parse_binary_value(self, data, display, length, format):
         if length is None:
-            return str(data), ''
+            try:
+                return data.decode('UTF-8'), b''
+            except UnicodeDecodeError:
+                return data, b''
 
         if self.pad:
             slen = length + ((4 - length % 4) % 4)
         else:
             slen = length
 
-        return str(data[:length]), buffer(data, slen)
+        s = data[:length]
+        try:
+            s = s.decode('UTF-8')
+        except UnicodeDecodeError:
+            pass  # return as bytes
+        return s, data[slen:]
 
 
 class String16(ValueField):
@@ -406,30 +427,30 @@
 
     def pack_value(self, val):
         # Convert 8-byte string into 16-byte list
-        if type(val) is types.StringType:
-            val = map(lambda c: ord(c), val)
+        if type(val) is str:
+            val = list(map(lambda c: ord(c), val))
 
         slen = len(val)
 
         if self.pad:
-            pad = '\0\0' * (slen % 2)
+            pad = b'\0\0' * (slen % 2)
         else:
-            pad = ''
+            pad = b''
 
-        return apply(struct.pack, ('>' + 'H' * slen, ) + tuple(val)) + pad, slen, None
+        return struct.pack(*('>' + 'H' * slen, ) + tuple(val)) + pad, slen, None
 
     def parse_binary_value(self, data, display, length, format):
         if length == 'odd':
-            length = len(data) / 2 - 1
+            length = len(data) // 2 - 1
         elif length == 'even':
-            length = len(data) / 2
+            length = len(data) // 2
 
         if self.pad:
             slen = length + (length % 2)
         else:
             slen = length
 
-        return struct.unpack('>' + 'H' * length, data[:length * 2]), buffer(data, slen * 2)
+        return struct.unpack('>' + 'H' * length, data[:length * 2]), data[slen * 2:]
 
 
 
@@ -473,7 +494,7 @@
 
                     pos = pos + slen
 
-                data = buffer(data, pos)
+                data = data[pos:]
 
         else:
             ret = [None] * int(length)
@@ -498,10 +519,10 @@
 
                     pos = pos + slen
 
-                data = buffer(data, pos)
+                data = data[pos:]
 
         if self.pad:
-            data = buffer(data, len(data) % 4)
+            data = data[len(data) % 4:]
 
         return ret, data
 
@@ -515,11 +536,11 @@
             for v in val:
                 data.append(self.type.pack_value(v))
 
-            data = string.join(data, '')
+            data = b''.join(data)
 
         if self.pad:
             dlen = len(data)
-            data = data + '\0' * ((4 - dlen % 4) % 4)
+            data = data + b'\0' * ((4 - dlen % 4) % 4)
 
         return data, len(val), None
 
@@ -562,7 +583,7 @@
             if self.type.parse_value is not None:
                 v = self.type.parse_value(v, display)
 
-            return v, buffer(data, slen)
+            return v, data[slen:]
 
     def parse_value(self, val, display):
         if self.type.parse_value is None:
@@ -581,10 +602,10 @@
         if self.type.structcode is None:
             return val
 
-        if type(val) is types.TupleType:
+        if type(val) is tuple:
             return val
 
-        if type(val) is types.DictType:
+        if type(val) is dict:
             data = val
         elif isinstance(val, DictWrapper):
             data = val._data
@@ -604,24 +625,31 @@
 
     def parse_binary_value(self, data, display, length, format):
         if length is None:
-            length = len(data) / (format / 8)
+            length = len(data) // (format // 8)
         else:
             length = int(length)
 
         if format == 0:
             ret = None
+            return ret, data
 
         elif format == 8:
-            ret = (8, str(data[:length]))
-            data = buffer(data, length + ((4 - length % 4) % 4))
+            ret = (8, data[:length])
+            data = data[length + ((4 - length % 4) % 4):]
 
         elif format == 16:
-            ret = (16, array(array_unsigned_codes[2], str(data[:2 * length])))
-            data = buffer(data, 2 * (length + length % 2))
+            ret = (16, array(array_unsigned_codes[2], data[:2 * length]))
+            data = data[2 * (length + length % 2):]
 
         elif format == 32:
-            ret = (32, array(array_unsigned_codes[4], str(data[:4 * length])))
-            data = buffer(data, 4 * length)
+            ret = (32, array(array_unsigned_codes[4], data[:4 * length]))
+            data = data[4 * length:]
+
+        if type(ret[1]) is bytes:
+            try:
+                ret = (ret[0], ret[1].decode('UTF-8'))
+            except UnicodeDecodeError:
+                pass  # return as bytes
 
         return ret, data
 
@@ -631,8 +659,11 @@
         if fmt not in (8, 16, 32):
             raise BadDataError('Invalid property data format %d' % fmt)
 
-        if type(val) is types.StringType:
-            size = fmt / 8
+        if _PY3 and type(val) is str:
+            val = val.encode('UTF-8')
+
+        if type(val) is bytes:
+            size = fmt // 8
             vlen = len(val)
             if vlen % size:
                 vlen = vlen - vlen % size
@@ -640,18 +671,18 @@
             else:
                 data = val
 
-            dlen = vlen / size
+            dlen = vlen // size
 
         else:
-            if type(val) is types.TupleType:
+            if type(val) is tuple:
                 val = list(val)
 
-            size = fmt / 8
+            size = fmt // 8
             data =  array(array_unsigned_codes[size], val).tostring()
             dlen = len(val)
 
         dl = len(data)
-        data = data + '\0' * ((4 - dl % 4) % 4)
+        data = data + b'\0' * ((4 - dl % 4) % 4)
 
         return data, dlen, fmt
 
@@ -663,7 +694,7 @@
 
     def parse_binary_value(self, data, display, length, format):
         return PropertyData.parse_binary_value(self, data, display,
-                                               self.size / (format / 8), format)
+                                               self.size // (format // 8), format)
 
     def pack_value(self, value):
         data, dlen, fmt = PropertyData.pack_value(self, value)
@@ -694,13 +725,13 @@
 
     def pack_value(self, arg, keys):
         mask = 0
-        data = ''
+        data = b''
 
         if arg == self.default:
             arg = keys
 
         for field, flag in self.fields:
-            if arg.has_key(field.name):
+            if field.name in arg:
                 mask = mask | flag
 
                 val = arg[field.name]
@@ -708,7 +739,7 @@
                     val = field.check_value(val)
 
                 d = struct.pack('=' + field.structcode, val)
-                data = data + d + '\0' * (4 - len(d))
+                data = data + d + b'\0' * (4 - len(d))
 
         return struct.pack(self.maskcode, mask) + data, None, None
 
@@ -716,7 +747,7 @@
         r = {}
 
         mask = int(struct.unpack(self.maskcode, data[:self.maskcodelen])[0])
-        data = buffer(data, self.maskcodelen)
+        data = data[self.maskcodelen:]
 
         for field, flag in self.fields:
             if mask & flag:
@@ -733,7 +764,7 @@
                     vals, d = field.parse_binary_value(data[:4], display, None, None)
 
                 r[field.name] = vals
-                data = buffer(data, 4)
+                data = data[4:]
 
         return DictWrapper(r), data
 
@@ -747,13 +778,13 @@
         else:
             dlen = 4 * length * format
 
-        a = array(array_unsigned_codes[4], str(data[:dlen]))
+        a = array(array_unsigned_codes[4], data[:dlen])
 
         ret = []
         for i in range(0, len(a), format):
             ret.append(a[i : i + format])
 
-        return ret, buffer(data, dlen)
+        return ret, data[dlen:]
 
     def pack_value(self, value):
         keycodes = 0
@@ -775,13 +806,13 @@
     structcode = None
 
     def parse_binary_value(self, data, display, length, format):
-        a = array(array_unsigned_codes[1], str(data[:8 * format]))
+        a = array(array_unsigned_codes[1], data[:8 * format])
 
         ret = []
         for i in range(0, 8):
             ret.append(a[i * format : (i + 1) * format])
 
-        return ret, buffer(data, 8 * format)
+        return ret, data[8 * format:]
 
     def pack_value(self, value):
         if len(value) != 8:
@@ -811,11 +842,11 @@
         return value._binary, None, None
 
     def parse_binary_value(self, data, display, length, format):
-        import event
+        from Xlib.protocol import event
 
-        estruct = display.event_classes.get(ord(data[0]) & 0x7f, event.AnyEvent)
+        estruct = display.event_classes.get(_bytes_item(data[0]) & 0x7f, event.AnyEvent)
 
-        return estruct(display = display, binarydata = data[:32]), buffer(data, 32)
+        return estruct(display = display, binarydata = data[:32]), data[32:]
 
 
 #
@@ -856,11 +887,22 @@
     structcode = None
 
     def pack_value(self, val):
-        return chr(len(val)) + val
+        if type(val) is not bytes:
+            val = val.encode('UTF-8')
+        if _PY3:
+            val = bytes([len(val)]) + val
+        else:
+            val = chr(len(val)) + val
+        return val
 
     def parse_binary(self, data, display):
-        slen = ord(data[0]) + 1
-        return data[1:slen], buffer(data, slen)
+        slen = _bytes_item(data[0]) + 1
+        s = data[1:slen]
+        try:
+            s = s.decode('UTF-8')
+        except UnicodeDecodeError:
+            pass  # return as bytes
+        return s, data[slen:]
 
 Str = StrClass()
 
@@ -979,6 +1021,7 @@
         # static fields.  First argument is the structcode, the
         # remaining are values.
 
+
         pack_args = ['"%s"' % self.static_codes]
 
         i = 0
@@ -1028,9 +1071,9 @@
 
                     if f.check_value is not None:
                         code = code + ('  %s = self.static_fields[%d].check_value(%s)\n'
-                                       % (string.join(a, ', '), i, f.name))
+                                       % (', '.join(a), i, f.name))
                     else:
-                        code = code + '  %s = %s\n' % (string.join(a, ', '), f.name)
+                        code = code + '  %s = %s\n' % (', '.join(a), f.name)
 
                     pack_args = pack_args + a
 
@@ -1043,14 +1086,13 @@
 
             i = i + 1
 
-
         # Construct call to struct.pack
-        pack = 'struct.pack(%s)' % string.join(pack_args, ', ')
+        pack = 'struct.pack(%s)' % ', '.join(pack_args)
 
         # If there are any varfields, we append the packed strings to build
         # the resulting binary value
         if self.var_fields:
-            code = code + '  return %s + %s\n' % (pack, string.join(joins, ' + '))
+            code = code + '  return %s + %s\n' % (pack, ' + '.join(joins))
 
         # If there's only static fields, return the packed value
         else:
@@ -1070,7 +1112,7 @@
             args.append('**_keyword_args')
 
         # Add function header
-        code = 'def to_binary(self, %s):\n' % string.join(args, ', ') + code
+        code = 'def to_binary(self, %s):\n' % ', '.join(args) + code
 
         # self._pack_code = code
 
@@ -1088,11 +1130,12 @@
         # memory leak isn't that serious.  Besides, Python 2.0 has
         # real garbage collect.
 
-        exec code
-        self.to_binary = new.instancemethod(to_binary, self, self.__class__)
+        g = globals().copy()
+        exec(code, g)
+        self.to_binary = types.MethodType(g['to_binary'], self)
 
         # Finally call it manually
-        return apply(self.to_binary, varargs, keys)
+        return self.to_binary(*varargs, **keys)
 
 
     def pack_value(self, value):
@@ -1103,12 +1146,12 @@
 
         """
 
-        if type(value) is types.TupleType:
-            return apply(self.to_binary, value, {})
-        elif type(value) is types.DictionaryType:
-            return apply(self.to_binary, (), value)
+        if type(value) is tuple:
+            return self.to_binary(*value, **{})
+        elif type(value) is dict:
+            return self.to_binary(*(), **value)
         elif isinstance(value, DictWrapper):
-            return apply(self.to_binary, (), value._data)
+            return self.to_binary(*(), **value._data)
         else:
             raise BadDataError('%s is not a tuple or a list' % (value))
 
@@ -1173,8 +1216,9 @@
 
         # Finally, compile function as for to_binary.
 
-        exec code
-        self.parse_value = new.instancemethod(parse_value, self, self.__class__)
+        g = globals().copy()
+        exec(code, g)
+        self.parse_value = types.MethodType(g['parse_value'], self)
 
         # Call it manually
         return self.parse_value(val, display, rawdict)
@@ -1249,7 +1293,7 @@
             fno = fno + 1
             vno = vno + f.structvalues
 
-        code = code + '  data = buffer(data, %d)\n' % self.static_size
+        code = code + '  data = data[%d:]\n' % self.static_size
 
         # Call parse_binary_value for each var_field, passing the
         # length and format values from the unpacked val.
@@ -1273,8 +1317,9 @@
 
         # Finally, compile function as for to_binary.
 
-        exec code
-        self.parse_binary = new.instancemethod(parse_binary, self, self.__class__)
+        g = globals().copy()
+        exec(code, g)
+        self.parse_binary = types.MethodType(g['parse_binary'], self)
 
         # Call it manually
         return self.parse_binary(data, display, rawdict)
@@ -1286,46 +1331,49 @@
                               String8('string', pad = 0) )
 
     def pack_value(self, value):
-        data = ''
+        data = b''
         args = {}
 
         for v in value:
             # Let values be simple strings, meaning a delta of 0
-            if type(v) is types.StringType:
+            if _PY3 and type(v) is str:
+                v = v.encode('UTF-8')
+
+            if type(v) is bytes:
                 v = (0, v)
 
             # A tuple, it should be (delta, string)
             # Encode it as one or more textitems
 
-            if type(v) in (types.TupleType, types.DictType) or \
+            if type(v) in (tuple, dict) or \
                isinstance(v, DictWrapper):
 
-                if type(v) is types.TupleType:
-                    delta, str = v
+                if type(v) is tuple:
+                    delta, s = v
                 else:
                     delta = v['delta']
-                    str = v['string']
+                    s = v['string']
 
-                while delta or str:
+                while delta or s:
                     args['delta'] = delta
-                    args['string'] = str[:254]
+                    args['string'] = s[:254]
 
-                    data = data + apply(self.string_textitem.to_binary, (), args)
+                    data = data + self.string_textitem.to_binary(*(), **args)
 
                     delta = 0
-                    str = str[254:]
+                    s = s[254:]
 
             # Else an integer, i.e. a font change
             else:
                 # Use fontable cast function if instance
-                if type(v) is types.InstanceType:
+                if hasattr(v, '__fontable__'):
                     v = v.__fontable__()
 
                 data = data + struct.pack('>BL', 255, v)
 
         # Pad out to four byte length
         dlen = len(data)
-        return data + '\0' * ((4 - dlen % 4) % 4), None, None
+        return data + b'\0' * ((4 - dlen % 4) % 4), None, None
 
     def parse_binary_value(self, data, display, length, format):
         values = []
@@ -1334,20 +1382,20 @@
                 break
 
             # font change
-            if ord(data[0]) == 255:
-                values.append(struct.unpack('>L', str(data[1:5]))[0])
-                data = buffer(data, 5)
+            if _bytes_item(data[0]) == 255:
+                values.append(struct.unpack('>L', data[1:5])[0])
+                data = data[5:]
 
             # skip null strings
-            elif ord(data[0]) == 0 and ord(data[1]) == 0:
-                data = buffer(data, 2)
+            elif _bytes_item(data[0]) == 0 and _bytes_item(data[1]) == 0:
+                data = data[2:]
 
             # string with delta
             else:
                 v, data = self.string_textitem.parse_binary(data, display)
                 values.append(v)
 
-        return values, ''
+        return values, b''
 
 
 
@@ -1358,7 +1406,7 @@
 
 
 
-class GetAttrData:
+class GetAttrData(object):
     def __getattr__(self, attr):
         try:
             if self._data:
@@ -1393,17 +1441,19 @@
     def __repr__(self):
         return '%s(%s)' % (self.__class__, repr(self._data))
 
-    def __cmp__(self, other):
+    def __eq__(self, other):
         if isinstance(other, DictWrapper):
-            return cmp(self._data, other._data)
+            return self._data == other._data
         else:
-            return cmp(self._data, other)
+            return self._data == other
 
+    def __ne__(self, other):
+        return not self.__eq__(other)
 
 class Request:
     def __init__(self, display, onerror = None, *args, **keys):
         self._errorhandler = onerror
-        self._binary = apply(self._request.to_binary, args, keys)
+        self._binary = self._request.to_binary(*args, **keys)
         self._serial = None
         display.send_request(self, onerror is not None)
 
@@ -1416,7 +1466,7 @@
 class ReplyRequest(GetAttrData):
     def __init__(self, display, defer = 0, *args, **keys):
         self._display = display
-        self._binary = apply(self._request.to_binary, args, keys)
+        self._binary = self._request.to_binary(*args, **keys)
         self._serial = None
         self._data = None
         self._error = None
@@ -1478,7 +1528,7 @@
 
             keys['sequence_number'] = 0
 
-            self._binary = apply(self._fields.to_binary, (), keys)
+            self._binary = self._fields.to_binary(*(), **keys)
 
             keys['send_event'] = 0
             self._data = keys
@@ -1492,16 +1542,15 @@
                 val = val | 0x80
             kwlist.append('%s = %s' % (kw, repr(val)))
 
-        kws = string.join(kwlist, ', ')
+        kws = ', '.join(kwlist)
         return '%s(%s)' % (self.__class__, kws)
 
-    def __cmp__(self, other):
+    def __eq__(self, other):
         if isinstance(other, Event):
-            return cmp(self._data, other._data)
+            return self._data == other._data
         else:
             return cmp(self._data, other)
 
-
 def call_error_handler(handler, error, request):
     try:
         return handler(error, request)
Index: python-xlib-0.14+20091101/Xlib/rdb.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/rdb.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/rdb.py	2013-10-11 14:19:21.089971348 -0400
@@ -22,13 +22,12 @@
 
 
 # Standard modules
-import string
-import types
 import re
 import sys
+import functools
 
 # Xlib modules
-from support import lock
+from Xlib.support import lock
 
 # Set up a few regexpes for parsing string representation of resources
 
@@ -69,7 +68,7 @@
 
         """
 
-        if type(file) is types.StringType:
+        if type(file) is str:
             file = open(file, 'r')
 
         self.insert_string(file.read())
@@ -84,7 +83,7 @@
         """
 
         # First split string into lines
-        lines = string.split(data, '\n')
+        lines = data.split('\n')
 
         while lines:
             line = lines[0]
@@ -122,15 +121,15 @@
             for i in range(1, len(splits), 2):
                 s = splits[i]
                 if len(s) == 3:
-                    splits[i] = chr(string.atoi(s, 8))
+                    splits[i] = chr(int(s, 8))
                 elif s == 'n':
                     splits[i] = '\n'
 
             # strip the last value part to get rid of any
             # unescaped blanks
-            splits[-1] = string.rstrip(splits[-1])
+            splits[-1] = splits[-1].rstrip()
 
-            value = string.join(splits, '')
+            value = ''.join(splits)
 
             self.insert(res, value)
 
@@ -172,7 +171,7 @@
         for i in range(1, len(parts), 2):
 
             # Create a new mapping/value group
-            if not db.has_key(parts[i - 1]):
+            if parts[i - 1] not in db:
                 db[parts[i - 1]] = ({}, {})
 
             # Use second mapping if a loose binding, first otherwise
@@ -182,24 +181,25 @@
                 db = db[parts[i - 1]][0]
 
         # Insert value into the derived db
-        if db.has_key(parts[-1]):
+        if parts[-1] in db:
             db[parts[-1]] = db[parts[-1]][:2] + (value, )
         else:
             db[parts[-1]] = ({}, {}, value)
 
         self.lock.release()
 
-    def __getitem__(self, (name, cls)):
+    def __getitem__(self, nc):
         """db[name, class]
 
         Return the value matching the resource identified by NAME and
         CLASS.  If no match is found, KeyError is raised.
         """
+        name, cls = nc
 
         # Split name and class into their parts
 
-        namep = string.split(name, '.')
-        clsp = string.split(cls, '.')
+        namep = name.split('.')
+        clsp = cls.split('.')
 
         # It is an error for name and class to have different number
         # of parts
@@ -218,13 +218,13 @@
 
             # Precedence order: name -> class -> ?
 
-            if self.db.has_key(namep[0]):
+            if namep[0] in self.db:
                 bin_insert(matches, _Match((NAME_MATCH, ), self.db[namep[0]]))
 
-            if self.db.has_key(clsp[0]):
+            if clsp[0] in self.db:
                 bin_insert(matches, _Match((CLASS_MATCH, ), self.db[clsp[0]]))
 
-            if self.db.has_key('?'):
+            if '?' in self.db:
                 bin_insert(matches, _Match((WILD_MATCH, ), self.db['?']))
 
 
@@ -240,7 +240,7 @@
 
             # Special case for resources which begins with a loose
             # binding, e.g. '*foo.bar'
-            if self.db.has_key(''):
+            if '' in self.db:
                 bin_insert(matches, _Match((), self.db[''][1]))
 
 
@@ -376,11 +376,12 @@
         return argv
 
 
+@functools.total_ordering
 class _Match:
     def __init__(self, path, dbs):
         self.path = path
 
-        if type(dbs) is types.TupleType:
+        if type(dbs) is tuple:
             self.skip = 0
             self.group = dbs
 
@@ -388,22 +389,25 @@
             self.skip = 1
             self.db = dbs
 
-    def __cmp__(self, other):
-        return cmp(self.path, other.path)
+    def __eq__(self, other):
+        return self.path == other.path
+
+    def __lt__(self, other):
+        return self.path < other.path
 
     def match_length(self):
         return len(self.path)
 
     def match(self, part, score):
         if self.skip:
-            if self.db.has_key(part):
+            if part in self.db:
                 return _Match(self.path + (score, ), self.db[part])
             else:
                 return None
         else:
-            if self.group[0].has_key(part):
+            if part in self.group[0]:
                 return _Match(self.path + (score, ), self.group[0][part])
-            elif self.group[1].has_key(part):
+            elif part in self.group[1]:
                 return _Match(self.path + (score + 1, ), self.group[1][part])
             else:
                 return None
@@ -460,7 +464,7 @@
     upper = len(list) - 1
 
     while lower <= upper:
-        center = (lower + upper) / 2
+        center = (lower + upper) // 2
         if element < list[center]:
             upper = center - 1
         elif element > list[center]:
@@ -482,7 +486,7 @@
     for comp, group in src.items():
 
         # DEST already contains this component, update it
-        if dest.has_key(comp):
+        if comp in dest:
 
             # Update tight and loose binding databases
             update_db(dest[comp][0], group[0])
@@ -536,7 +540,7 @@
                       ('\000', '\\000'),
                       ('\n', '\\n')):
 
-        value = string.replace(value, char, esc)
+        value = value.replace(char, esc)
 
     # If first or last character is space or tab, escape them.
     if value[0] in ' \t':
Index: python-xlib-0.14+20091101/Xlib/support/unix_connect.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/support/unix_connect.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/support/unix_connect.py	2013-10-11 14:19:21.089971348 -0400
@@ -17,7 +17,6 @@
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 import re
-import string
 import os
 import platform
 import socket
@@ -88,7 +87,7 @@
         else:
             s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
             s.connect('/tmp/.X11-unix/X%d' % dno)
-    except socket.error, val:
+    except socket.error as val:
         raise error.DisplayConnectionError(dname, str(val))
 
     # Make sure that the connection isn't inherited in child processes
@@ -108,8 +107,8 @@
 
         # Convert the prettyprinted IP number into 4-octet string.
         # Sometimes these modules are too damn smart...
-        octets = string.split(sock.getpeername()[0], '.')
-        addr = string.join(map(lambda x: chr(int(x)), octets), '')
+        octets = sock.getpeername()[0].split('.')
+        addr = ''.join(map(lambda x: chr(int(x)), octets))
     else:
         family = xauth.FamilyLocal
         addr = socket.gethostname()
@@ -145,9 +144,9 @@
         #      DISPLAY SCHEME COOKIE
         # We're interested in the two last parts for the
         # connection establishment
-        lines = string.split(data, '\n')
+        lines = data.split('\n')
         if len(lines) >= 1:
-            parts = string.split(lines[0], None, 2)
+            parts = lines[0].split(None, 2)
             if len(parts) == 3:
                 auth_name = parts[1]
                 hexauth = parts[2]
@@ -155,7 +154,7 @@
 
                 # Translate hexcode into binary
                 for i in range(0, len(hexauth), 2):
-                    auth = auth + chr(string.atoi(hexauth[i:i+2], 16))
+                    auth = auth + chr(int(hexauth[i:i+2], 16))
 
                 auth_data = auth
     except os.error:
@@ -167,7 +166,7 @@
 	# There might be more ways to spell 127.0.0.1 but
 	# 'localhost', yet this code fixes a the case of
 	# OpenSSH tunneling X.
-	return get_auth('unix:%d' % dno, 'unix', dno)
+        return get_auth('unix:%d' % dno, 'unix', dno)
 
     return auth_name, auth_data
 
Index: python-xlib-0.14+20091101/Xlib/support/vms_connect.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/support/vms_connect.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/support/vms_connect.py	2013-10-11 14:19:21.089971348 -0400
@@ -60,7 +60,7 @@
         s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         s.connect((host, 6000 + dno))
 
-    except socket.error, val:
+    except socket.error as val:
         raise error.DisplayConnectionError(dname, str(val))
 
     return s
Index: python-xlib-0.14+20091101/Xlib/xauth.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/xauth.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/xauth.py	2013-10-11 14:19:21.089971348 -0400
@@ -40,7 +40,7 @@
 
         try:
             raw = open(filename, 'rb').read()
-        except IOError, err:
+        except IOError as err:
             raise error.XauthError('~/.Xauthority: %s' % err)
 
         self.entries = []
@@ -82,12 +82,12 @@
                     break
 
                 self.entries.append((family, addr, num, name, data))
-        except struct.error, e:
-            print "Xlib.xauth: warning, failed to parse part of xauthority file (%s), aborting all further parsing" % filename
+        except struct.error as e:
+            print ("Xlib.xauth: warning, failed to parse part of xauthority file (%s), aborting all further parsing" % filename)
             #pass
 
         if len(self.entries) == 0:
-            print "Xlib.xauth: warning, no xauthority details available"
+            print ("Xlib.xauth: warning, no xauthority details available")
             # raise an error?  this should get partially caught by the XNoAuthError in get_best_auth..
 
     def __len__(self):
Index: python-xlib-0.14+20091101/Xlib/xobject/cursor.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/xobject/cursor.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/xobject/cursor.py	2013-10-11 14:19:21.089971348 -0400
@@ -17,8 +17,7 @@
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 from Xlib.protocol import request
-
-import resource
+from Xlib.xobject import resource
 
 class Cursor(resource.Resource):
     __cursor__ = resource.Resource.__resource__
@@ -29,9 +28,9 @@
                            cursor = self.id)
         self.display.free_resource_id(self.id)
 
-    def recolor(self, (fore_red, fore_green, fore_blue),
-                (back_red, back_green, back_blue), onerror = None):
-
+    def recolor(self, f_rgb, b_rgb, onerror = None):
+        back_red, back_green, back_blue = b_rgb
+        fore_red, fore_green, fore_blue = f_rgb
         request.RecolorCursor(display = self.display,
                               onerror = onerror,
                               cursor = self.id,
Index: python-xlib-0.14+20091101/Xlib/xobject/drawable.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/xobject/drawable.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/xobject/drawable.py	2013-10-11 14:21:48.317975118 -0400
@@ -16,19 +16,12 @@
 #    along with this program; if not, write to the Free Software
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-import string
 
 from Xlib import X, Xatom, Xutil
 from Xlib.protocol import request, rq
 
 # Other X resource objects
-import resource
-import colormap
-import cursor
-import fontable
-
-# Inter-client communication conventions
-import icccm
+from Xlib.xobject import resource, colormap, cursor, fontable, icccm
 
 class Drawable(resource.Resource):
     __drawable__ = resource.Resource.__resource__
@@ -231,11 +224,11 @@
             unit = self.display.info.bitmap_format_scanline_unit
             stride = roundup(width * unit, pad) >> 3
         else:
-            raise ValueError, 'Unknown data format'
+            raise ValueError('Unknown data format')
 
         maxlen = (self.display.info.max_request_length << 2) \
                  - request.PutImage._request.static_size
-        split = maxlen / stride
+        split = maxlen // stride
 
         x1 = 0
         x2 = width
@@ -461,7 +454,7 @@
             val = prop.value
             if prop.bytes_after:
                 prop = self.get_property(property, type, sizehint,
-                                         prop.bytes_after / 4 + 1)
+                                         prop.bytes_after // 4 + 1)
                 val = val + prop.value
 
             prop.value = val
@@ -668,7 +661,7 @@
         if d is None or d.format != 8:
             return None
         else:
-            parts = string.split(d.value, '\0')
+            parts = d.value.split('\0')
             if len(parts) < 2:
                 return None
             else:
@@ -765,7 +758,7 @@
     # Returns a DictWrapper, or None
 
     def _get_struct_prop(self, pname, ptype, pstruct):
-        r = self.get_property(pname, ptype, 0, pstruct.static_size / 4)
+        r = self.get_property(pname, ptype, 0, pstruct.static_size // 4)
         if r and r.format == 32:
             value = r.value.tostring()
             if len(value) == pstruct.static_size:
@@ -784,7 +777,7 @@
         else:
             keys.update(hints)
 
-        value = apply(pstruct.to_binary, (), keys)
+        value = pstruct.to_binary(*(), **keys)
 
         self.change_property(pname, ptype, 32, value, onerror = onerror)
 
@@ -800,9 +793,10 @@
         self.display.free_resource_id(self.id)
 
     def create_cursor(self, mask,
-                      (fore_red, fore_green, fore_blue),
-                      (back_red, back_green, back_blue),
+                      f_rgb, b_rgb,
                       x, y):
+        fore_red, fore_green, fore_blue = f_rgb
+        back_red, back_green, back_blue = b_rgb
         cid = self.display.allocate_resource_id()
         request.CreateCursor(display = self.display,
                              cid = cid,
Index: python-xlib-0.14+20091101/Xlib/xobject/fontable.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/xobject/fontable.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/xobject/fontable.py	2013-10-11 14:19:21.089971348 -0400
@@ -17,9 +17,7 @@
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 from Xlib.protocol import request
-
-import resource
-import cursor
+from Xlib.xobject import resource, cursor
 
 class Fontable(resource.Resource):
     __fontable__ = resource.Resource.__resource__
@@ -85,8 +83,9 @@
         self.display.free_resource_id(self.id)
 
     def create_glyph_cursor(self, mask, source_char, mask_char,
-                            (fore_red, fore_green, fore_blue),
-                            (back_red, back_green, back_blue)):
+                            f_rgb, b_rgb):
+        fore_red, fore_green, fore_blue = f_rgb
+        back_red, back_green, back_blue = b_rgb
 
         cid = self.display.allocate_resource_id()
         request.CreateGlyphCursor(display = self.display,
Index: python-xlib-0.14+20091101/examples/childwin.py
===================================================================
--- python-xlib-0.14+20091101.orig/examples/childwin.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/examples/childwin.py	2013-10-11 14:19:21.093971349 -0400
@@ -54,10 +54,10 @@
 
 		bggc.change(foreground=self.screen.white_pixel)
 
-		bgpm.arc(bggc, -bgsize / 2, 0, bgsize, bgsize, 0, 360 * 64)
-		bgpm.arc(bggc, bgsize / 2, 0, bgsize, bgsize, 0, 360 * 64)
-		bgpm.arc(bggc, 0, -bgsize / 2, bgsize, bgsize, 0, 360 * 64)
-		bgpm.arc(bggc, 0, bgsize / 2, bgsize, bgsize, 0, 360 * 64)
+		bgpm.arc(bggc, -bgsize // 2, 0, bgsize, bgsize, 0, 360 * 64)
+		bgpm.arc(bggc, bgsize // 2, 0, bgsize, bgsize, 0, 360 * 64)
+		bgpm.arc(bggc, 0, -bgsize // 2, bgsize, bgsize, 0, 360 * 64)
+		bgpm.arc(bggc, 0, bgsize // 2, bgsize, bgsize, 0, 360 * 64)
 
 		# Actual window
 		self.window = self.screen.root.create_window(
@@ -127,10 +127,10 @@
 			# Button released, add or subtract
 			elif e.type == X.ButtonRelease:
 				if e.detail == 1:
-					print "Moving child window."
+					print("Moving child window.")
 					self.childWindow.configure(
-						x=e.event_x - self.childWidth / 2,
-						y=e.event_y - self.childHeight / 2
+						x=e.event_x - self.childWidth // 2,
+						y=e.event_y - self.childHeight // 2
 						)
 					self.d.flush()
 
Index: python-xlib-0.14+20091101/examples/profilex.py
===================================================================
--- python-xlib-0.14+20091101.orig/examples/profilex.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/examples/profilex.py	2013-10-11 14:19:21.093971349 -0400
@@ -18,9 +18,9 @@
     r = d.screen().root
     cm = d.screen().default_colormap
 
-    for i in xrange(0, 1000):
+    for i in range(0, 1000):
         if i % 50 == 0:
-            print 'Iteration', i
+            print('Iteration %i' % i)
 
         r.delete_property(Xatom.WM_NORMAL_HINTS)
         r.delete_property(Xatom.WM_NORMAL_HINTS)
@@ -39,4 +39,4 @@
     if len(sys.argv) == 2:
         main(sys.argv[1])
     else:
-        print sys.argv[0], "<filename to write profile output to>"
+        print(sys.argv[0] + " <filename to write profile output to>")
Index: python-xlib-0.14+20091101/examples/record_demo.py
===================================================================
--- python-xlib-0.14+20091101.orig/examples/record_demo.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/examples/record_demo.py	2013-10-11 14:19:21.093971349 -0400
@@ -44,9 +44,9 @@
     if reply.category != record.FromServer:
         return
     if reply.client_swapped:
-        print "* received swapped protocol data, cowardly ignored"
+        print("* received swapped protocol data, cowardly ignored")
         return
-    if not len(reply.data) or ord(reply.data[0]) < 2:
+    if not len(reply.data) or reply.data[0] < 2:
         # not an event
         return
 
@@ -59,28 +59,28 @@
 
             keysym = local_dpy.keycode_to_keysym(event.detail, 0)
             if not keysym:
-                print "KeyCode%s" % pr, event.detail
+                print("KeyCode%s %s" % (pr, event.detail))
             else:
-                print "KeyStr%s" % pr, lookup_keysym(keysym)
+                print("KeyStr%s %s" % (pr, lookup_keysym(keysym)))
 
             if event.type == X.KeyPress and keysym == XK.XK_Escape:
                 local_dpy.record_disable_context(ctx)
                 local_dpy.flush()
                 return
         elif event.type == X.ButtonPress:
-            print "ButtonPress", event.detail
+            print("ButtonPress %s" % event.detail)
         elif event.type == X.ButtonRelease:
-            print "ButtonRelease", event.detail
+            print("ButtonRelease %s" % event.detail)
         elif event.type == X.MotionNotify:
-            print "MotionNotify", event.root_x, event.root_y
+            print("MotionNotify %i %i" % (event.root_x, event.root_y))
 
 
 # Check if the extension is present
 if not record_dpy.has_extension("RECORD"):
-    print "RECORD extension not found"
+    print("RECORD extension not found")
     sys.exit(1)
 r = record_dpy.record_get_version(0, 0)
-print "RECORD extension version %d.%d" % (r.major_version, r.minor_version)
+print("RECORD extension version %d.%d" % (r.major_version, r.minor_version))
 
 # Create a recording context; we only want key and mouse events
 ctx = record_dpy.record_create_context(
Index: python-xlib-0.14+20091101/examples/shapewin.py
===================================================================
--- python-xlib-0.14+20091101.orig/examples/shapewin.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/examples/shapewin.py	2013-10-11 14:19:21.093971349 -0400
@@ -41,7 +41,7 @@
 
         # print version
         r = self.d.shape_query_version()
-        print 'SHAPE version %d.%d' % (r.major_version, r.minor_version)
+        print('SHAPE version %d.%d' % (r.major_version, r.minor_version))
 
 
         # Find which screen to open the window on
@@ -59,10 +59,10 @@
 
         bggc.change(foreground = self.screen.white_pixel)
 
-        bgpm.arc(bggc, -bgsize / 2, 0, bgsize, bgsize, 0, 360 * 64)
-        bgpm.arc(bggc, bgsize / 2, 0, bgsize, bgsize, 0, 360 * 64)
-        bgpm.arc(bggc, 0, -bgsize / 2, bgsize, bgsize, 0, 360 * 64)
-        bgpm.arc(bggc, 0, bgsize / 2, bgsize, bgsize, 0, 360 * 64)
+        bgpm.arc(bggc, -bgsize // 2, 0, bgsize, bgsize, 0, 360 * 64)
+        bgpm.arc(bggc, bgsize // 2, 0, bgsize, bgsize, 0, 360 * 64)
+        bgpm.arc(bggc, 0, -bgsize // 2, bgsize, bgsize, 0, 360 * 64)
+        bgpm.arc(bggc, 0, bgsize // 2, bgsize, bgsize, 0, 360 * 64)
 
         # Actual window
         self.window = self.screen.root.create_window(
@@ -112,10 +112,10 @@
         self.sub_pm.fill_rectangle(gc, 0, 0, self.sub_size, self.sub_size)
         gc.change(foreground = 1)
         self.sub_pm.fill_poly(gc, X.Convex, X.CoordModeOrigin,
-                              [(self.sub_size / 2, 0),
-                               (self.sub_size, self.sub_size / 2),
-                               (self.sub_size / 2, self.sub_size),
-                               (0, self.sub_size / 2)])
+                              [(self.sub_size // 2, 0),
+                               (self.sub_size, self.sub_size // 2),
+                               (self.sub_size // 2, self.sub_size),
+                               (0, self.sub_size // 2)])
         gc.free()
 
         # Set initial mask
@@ -151,19 +151,19 @@
                 if e.detail == 1:
                     self.window.shape_mask(shape.ShapeUnion,
                                            shape.ShapeBounding,
-                                           e.event_x - self.add_size / 2,
-                                           e.event_y - self.add_size / 2,
+                                           e.event_x - self.add_size // 2,
+                                           e.event_y - self.add_size // 2,
                                            self.add_pm)
                 elif e.detail == 3:
                     self.window.shape_mask(shape.ShapeSubtract,
                                            shape.ShapeBounding,
-                                           e.event_x - self.sub_size / 2,
-                                           e.event_y - self.sub_size / 2,
+                                           e.event_x - self.sub_size // 2,
+                                           e.event_y - self.sub_size // 2,
                                            self.sub_pm)
 
             # Shape has changed
             elif e.type == self.d.extension_event.ShapeNotify:
-                print 'Shape change'
+                print('Shape change')
 
             # Somebody wants to tell us something
             elif e.type == X.ClientMessage:
Index: python-xlib-0.14+20091101/examples/threadtest.py
===================================================================
--- python-xlib-0.14+20091101.orig/examples/threadtest.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/examples/threadtest.py	2013-10-11 14:19:21.093971349 -0400
@@ -7,7 +7,13 @@
 
 from Xlib import display, X, threaded
 import time
-import thread
+
+try:
+    # Python 3
+    import _thread as thread
+except ImportError:
+    # Python 2
+    import thread
 
 def redraw(win, gc):
     # win.clear_area()
@@ -16,7 +22,7 @@
 def blink(display, win, gc, cols):
     while 1:
         time.sleep(2)
-        print 'Changing color', cols[0]
+        print('Changing color %i' % cols[0])
         gc.change(foreground = cols[0])
         cols = (cols[1], cols[0])
         redraw(win, gc)
Index: python-xlib-0.14+20091101/examples/xinerama.py
===================================================================
--- python-xlib-0.14+20091101.orig/examples/xinerama.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/examples/xinerama.py	2013-10-11 14:19:21.093971349 -0400
@@ -36,14 +36,14 @@
         if not self.d.has_extension('XINERAMA'):
             sys.stderr.write('%s: server does not have the XINERAMA extension\n'
                              % sys.argv[0])
-            print self.d.query_extension('XINERAMA')
+            print(self.d.query_extension('XINERAMA'))
             sys.stderr.write("\n".join(self.d.list_extensions()))
             if self.d.query_extension('XINERAMA') is None:
                 sys.exit(1)
 
         # print version
         r = self.d.xinerama_query_version()
-        print 'XINERAMA version %d.%d' % (r.major_version, r.minor_version)
+        print('XINERAMA version %d.%d' % (r.major_version, r.minor_version))
 
 
         # Grab the current screen
@@ -93,23 +93,23 @@
 
         self.pp = pprint.PrettyPrinter(indent=4)
 
-        print "Xinerama active:", bool(self.d.xinerama_is_active())
+        print("Xinerama active:" + str(bool(self.d.xinerama_is_active())))
 
-        print "Screen info:"
+        print("Screen info:")
         self.pp.pprint(self.d.xinerama_query_screens()._data)
 
         # FIXME: This doesn't work!
         #print "Xinerama info:"
         #self.pp.pprint(self.d.xinerama_get_info(self.d.screen().root_visual)._data)
 
-        print "Xinerama state:"
+        print("Xinerama state:")
         self.pp.pprint(self.window.xinerama_get_state()._data)
 
-        print "Screen count:"
+        print("Screen count:")
         self.pp.pprint(self.window.xinerama_get_screen_count()._data)
 
         for screennum in range(self.window.xinerama_get_screen_count().screen_count):
-            print "Screen %d size:" % (screennum, )
+            print("Screen %d size:" % (screennum, ))
             self.pp.pprint(self.window.xinerama_get_screen_size(screennum)._data)
 
     def parseModes(self, mode_names, modes):
Index: python-xlib-0.14+20091101/examples/xrandr.py
===================================================================
--- python-xlib-0.14+20091101.orig/examples/xrandr.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/examples/xrandr.py	2013-10-11 14:19:21.093971349 -0400
@@ -36,14 +36,14 @@
         if not self.d.has_extension('RANDR'):
             sys.stderr.write('%s: server does not have the RANDR extension\n'
                              % sys.argv[0])
-            print self.d.query_extension('RANDR')
+            print(self.d.query_extension('RANDR'))
             sys.stderr.write("\n".join(self.d.list_extensions()))
             if self.d.query_extension('RANDR') is None:
                 sys.exit(1)
 
         # print version
         r = self.d.xrandr_query_version()
-        print 'RANDR version %d.%d' % (r.major_version, r.minor_version)
+        print('RANDR version %d.%d' % (r.major_version, r.minor_version))
 
 
         # Grab the current screen
@@ -101,30 +101,30 @@
 
         self.pp = pprint.PrettyPrinter(indent=4)
 
-        print "Screen info:"
+        print("Screen info:")
         self.pp.pprint(self.window.xrandr_get_screen_info()._data)
 
-        print "Screen size range:"
+        print("Screen size range:")
         self.pp.pprint(self.window.xrandr_get_screen_size_range()._data)
 
-        print "Primary output:"
+        print("Primary output:")
         self.pp.pprint(self.window.xrandr_get_output_primary()._data)
 
         resources = self.window.xrandr_get_screen_resources()._data
 
-        print "Modes:"
-        for mode_id, mode in self.parseModes(resources['mode_names'], resources['modes']).iteritems():
-            print "    %d: %s" % (mode_id, mode['name'])
+        print("Modes:")
+        for mode_id, mode in self.parseModes(resources['mode_names'], resources['modes']).items():
+            print("    %d: %s" % (mode_id, mode['name']))
 
         for output in resources['outputs']:
-            print "Output %d info:" % (output, )
+            print("Output %d info:" % (output, ))
             self.pp.pprint(self.d.xrandr_get_output_info(output, resources['config_timestamp'])._data)
 
         for crtc in resources['crtcs']:
-            print "CRTC %d info:" % (crtc, )
+            print("CRTC %d info:" % (crtc, ))
             self.pp.pprint(self.d.xrandr_get_crtc_info(crtc, resources['config_timestamp'])._data)
 
-        print "Raw screen resources:"
+        print("Raw screen resources:")
         self.pp.pprint(resources)
 
     def parseModes(self, mode_names, modes):
@@ -149,23 +149,23 @@
 
             # Screen information has changed
             elif e.type == self.d.extension_event.ScreenChangeNotify:
-                print 'Screen change'
-                print self.pp.pprint(e._data)
+                print('Screen change')
+                print(self.pp.pprint(e._data))
 
             # CRTC information has changed
             elif e.type == self.d.extension_event.CrtcChangeNotify:
-                print 'CRTC change'
-                print self.pp.pprint(e._data)
+                print('CRTC change')
+                print(self.pp.pprint(e._data))
 
             # Output information has changed
             elif e.type == self.d.extension_event.OutputChangeNotify:
-                print 'Output change'
-                print self.pp.pprint(e._data)
+                print('Output change')
+                print(self.pp.pprint(e._data))
 
             # Output property information has changed
             elif e.type == self.d.extension_event.OutputPropertyNotify:
-                print 'Output property change'
-                print self.pp.pprint(e._data)
+                print('Output property change')
+                print(self.pp.pprint(e._data))
 
             # Somebody wants to tell us something
             elif e.type == X.ClientMessage:
Index: python-xlib-0.14+20091101/Xlib/display.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/display.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/display.py	2013-10-11 14:19:21.093971349 -0400
@@ -17,34 +17,31 @@
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 # Python modules
-import new
+import types
 
 # Xlib modules
-import error
-import ext
-import X
+from Xlib import error, ext, X
 
 # Xlib.protocol modules
-import protocol.display
-from protocol import request, event, rq
+from Xlib.protocol import display, request, event, rq
 
 # Xlib.xobjects modules
-import xobject.resource
-import xobject.drawable
-import xobject.fontable
-import xobject.colormap
-import xobject.cursor
+import Xlib.xobject.resource
+import Xlib.xobject.drawable
+import Xlib.xobject.fontable
+import Xlib.xobject.colormap
+import Xlib.xobject.cursor
 
 _resource_baseclasses = {
-    'resource': xobject.resource.Resource,
-    'drawable': xobject.drawable.Drawable,
-    'window': xobject.drawable.Window,
-    'pixmap': xobject.drawable.Pixmap,
-    'fontable': xobject.fontable.Fontable,
-    'font': xobject.fontable.Font,
-    'gc': xobject.fontable.GC,
-    'colormap': xobject.colormap.Colormap,
-    'cursor': xobject.cursor.Cursor,
+    'resource': Xlib.xobject.resource.Resource,
+    'drawable': Xlib.xobject.drawable.Drawable,
+    'window': Xlib.xobject.drawable.Window,
+    'pixmap': Xlib.xobject.drawable.Pixmap,
+    'fontable': Xlib.xobject.fontable.Fontable,
+    'font': Xlib.xobject.fontable.Font,
+    'gc': Xlib.xobject.fontable.GC,
+    'colormap': Xlib.xobject.colormap.Colormap,
+    'cursor': Xlib.xobject.cursor.Cursor,
     }
 
 _resource_hierarchy = {
@@ -55,18 +52,18 @@
     'fontable': ('font', 'gc')
     }
 
-class _BaseDisplay(protocol.display.Display):
+class _BaseDisplay(display.Display):
     resource_classes = _resource_baseclasses.copy()
 
     # Implement a cache of atom names, used by Window objects when
     # dealing with some ICCCM properties not defined in Xlib.Xatom
 
     def __init__(self, *args, **keys):
-        apply(protocol.display.Display.__init__, (self, ) + args, keys)
+        display.Display.__init__(*(self, ) + args, **keys)
         self._atom_cache = {}
 
     def get_atom(self, atomname, only_if_exists=0):
-        if self._atom_cache.has_key(atomname):
+        if atomname in self._atom_cache:
             return self._atom_cache[atomname]
 
         r = request.InternAtom(display = self, name = atomname, only_if_exists = only_if_exists)
@@ -119,11 +116,11 @@
 
 
         # Finalize extensions by creating new classes
-        for type, dict in self.class_extension_dicts.items():
-            origcls = self.display.resource_classes[type]
-            self.display.resource_classes[type] = new.classobj(origcls.__name__,
-                                                               (origcls,),
-                                                               dict)
+        for type_, dict in self.class_extension_dicts.items():
+            origcls = self.display.resource_classes[type_]
+            self.display.resource_classes[type_] = type(origcls.__name__,
+                                                        (origcls, object),
+                                                        dict)
 
         # Problem: we have already created some objects without the
         # extensions: the screen roots and default colormaps.
@@ -211,7 +208,7 @@
     def __getattr__(self, attr):
         try:
             function = self.display_extension_methods[attr]
-            return new.instancemethod(function, self, self.__class__)
+            return types.MethodType(function, self)
         except KeyError:
             raise AttributeError(attr)
 
@@ -272,13 +269,11 @@
                 if hasattr(cls, name):
                     raise error.MethodOverrideError('attempting to replace %s method: %s' % (type, name))
 
-                method = new.instancemethod(function, None, cls)
-
                 # Maybe should check extension overrides too
                 try:
-                    self.class_extension_dicts[type][name] = method
+                    self.class_extension_dicts[type][name] = function
                 except KeyError:
-                    self.class_extension_dicts[type] = { name: method }
+                    self.class_extension_dicts[type] = { name: function }
 
     def extension_add_event(self, code, evt, name = None):
         """extension_add_event(code, evt, [name])
@@ -292,8 +287,8 @@
         extension_event.
         """
 
-        newevt = new.classobj(evt.__name__, evt.__bases__,
-                              evt.__dict__.copy())
+        newevt = type(evt.__name__, evt.__bases__,
+                      evt.__dict__.copy())
         newevt._code = code
 
         self.display.add_extension_event(code, newevt)
@@ -395,7 +390,7 @@
             index = 0
             for sym in syms:
                 if sym != X.NoSymbol:
-                    if self._keymap_syms.has_key(sym):
+                    if sym in self._keymap_syms:
                         symcodes = self._keymap_syms[sym]
                         symcodes.append((index, code))
                         symcodes.sort()
@@ -595,7 +590,7 @@
             self.display.free_resource_id(fid)
             return None
         else:
-            cls = self.display.get_resource_class('font', xobject.fontable.Font)
+            cls = self.display.get_resource_class('font', Xlib.xobject.fontable.Font)
             return cls(self.display, fid, owner = 1)
 
     def list_fonts(self, pattern, max_names):
Index: python-xlib-0.14+20091101/Xlib/protocol/request.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/protocol/request.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/protocol/request.py	2013-10-11 14:19:21.097971349 -0400
@@ -21,8 +21,7 @@
 from Xlib import X
 
 # Xlib.protocol modules
-import rq
-import structs
+from Xlib.protocol import rq, structs
 
 
 class CreateWindow(rq.Request):
@@ -784,7 +783,7 @@
 
     def __init__(self, *args, **keys):
         self._fonts = []
-        apply(ReplyRequest.__init__, (self, ) + args, keys)
+        ReplyRequest.__init__(*(self, ) + args, **keys)
 
     def _parse_response(self, data):
 
Index: python-xlib-0.14+20091101/Xlib/protocol/structs.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/protocol/structs.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/protocol/structs.py	2013-10-11 14:19:21.097971349 -0400
@@ -20,7 +20,7 @@
 from Xlib import X
 
 # Xlib.protocol modules
-import rq
+from Xlib.protocol import rq
 
 def WindowValues(arg):
     return rq.ValueList( arg, 4, 0,
Index: python-xlib-0.14+20091101/Xlib/support/connect.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/support/connect.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/support/connect.py	2013-10-11 14:19:21.097971349 -0400
@@ -17,7 +17,6 @@
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 import sys
-import string
 
 # List the modules which contain the corresponding functions
 
@@ -43,7 +42,7 @@
 # Figure out which OS we're using.
 # sys.platform is either "OS-ARCH" or just "OS".
 
-_parts = string.split(sys.platform, '-')
+_parts = sys.platform.split('-')
 platform = _parts[0]
 del _parts
 
@@ -61,8 +60,8 @@
     """
 
     modname = _display_mods.get(platform, _default_display_mod)
-    mod = __import__(modname, globals())
-    return mod.get_display(display)
+    mod = __import__('Xlib.support', globals(), fromlist=(modname,))
+    return getattr(mod, modname).get_display(display)
 
 
 def get_socket(dname, host, dno):
@@ -75,8 +74,8 @@
     """
 
     modname = _socket_mods.get(platform, _default_socket_mod)
-    mod = __import__(modname, globals())
-    return mod.get_socket(dname, host, dno)
+    mod = __import__('Xlib.support', globals(), fromlist=(modname,))
+    return getattr(mod, modname).get_socket(dname, host, dno)
 
 
 def get_auth(sock, dname, host, dno):
@@ -90,5 +89,5 @@
     """
 
     modname = _auth_mods.get(platform, _default_auth_mod)
-    mod = __import__(modname, globals())
-    return mod.get_auth(sock, dname, host, dno)
+    mod = __import__('Xlib.support', globals(), fromlist=(modname,))
+    return getattr(mod, modname).get_auth(sock, dname, host, dno)
Index: python-xlib-0.14+20091101/test/test_events_be.py
===================================================================
--- python-xlib-0.14+20091101.orig/test/test_events_be.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/test/test_events_be.py	2013-10-11 14:19:21.097971349 -0400
@@ -3,7 +3,6 @@
 import sys, os
 sys.path.insert(1, os.path.join(sys.path[0], '..'))
 
-import string
 import unittest
 from Xlib.protocol import request, rq, event
 import Xlib.protocol.event
@@ -13,7 +12,7 @@
 
 class CmpArray:
     def __init__(self, *args, **kws):
-        self.array = apply(array.array, args, kws)
+        self.array = array.array(*args, **kws)
 
     def __len__(self):
         return len(self.array)
@@ -24,13 +23,16 @@
     def __getattr__(self, attr):
         return getattr(self.array, attr)
 
-    def __cmp__(self, other):
-        return cmp(self.array.tolist(), other)
+    def __eq__(self, other):
+        return self.array.tolist() == other
+
+    def __ne__(self, other):
+        return self.array.tolist() != other
 
 rq.array = CmpArray
 
 def tohex(bin):
-    bin = string.join(map(lambda c: '\\x%02x' % ord(c), bin), '')
+    bin = ''.join(map(lambda c: '\\x%02x' % c, bin))
 
     bins = []
     for i in range(0, len(bin), 16):
@@ -43,7 +45,7 @@
         except IndexError:
             bins2.append("'%s'" % bins[i])
 
-    return string.join(bins2, ' \\\n            ')
+    return ' \\\n            '.join(bins2)
 
 class DummyDisplay:
     def get_resource_class(self, x):
@@ -66,14 +68,14 @@
             'type': 154,
             'data': [160, 192, 133, 223, 245, 128, 133, 188, 208, 142, 202, 142, 218, 238, 145, 150, 211, 150, 165, 230, 149, 162, 139, 159, 135, 255, 246, 202, 232, 185, 164],
             }
-        self.evt_bin_0 = '\x9a\xa0\xc0\x85' '\xdf\xf5\x80\x85' \
-            '\xbc\xd0\x8e\xca' '\x8e\xda\xee\x91' \
-            '\x96\xd3\x96\xa5' '\xe6\x95\xa2\x8b' \
-            '\x9f\x87\xff\xf6' '\xca\xe8\xb9\xa4'
+        self.evt_bin_0 = b'\x9a\xa0\xc0\x85' b'\xdf\xf5\x80\x85' \
+            b'\xbc\xd0\x8e\xca' b'\x8e\xda\xee\x91' \
+            b'\x96\xd3\x96\xa5' b'\xe6\x95\xa2\x8b' \
+            b'\x9f\x87\xff\xf6' b'\xca\xe8\xb9\xa4'
 
 
     def testPack0(self):
-        bin = apply(event.KeymapNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.KeymapNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -103,14 +105,14 @@
             'width': 26369,
             'count': 60118,
             }
-        self.evt_bin_0 = '\xfe\x00\xdb\xcc' '\x52\x5b\x35\x64' \
-            '\x42\x4e\x4d\x28' '\x67\x01\x56\xc6' \
-            '\xea\xd6\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xfe\x00\xdb\xcc' b'\x52\x5b\x35\x64' \
+            b'\x42\x4e\x4d\x28' b'\x67\x01\x56\xc6' \
+            b'\xea\xd6\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.Expose._fields.to_binary, (), self.evt_args_0)
+        bin = event.Expose._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -142,14 +144,14 @@
             'width': 58556,
             'minor_event': 22632,
             }
-        self.evt_bin_0 = '\xf2\x00\x18\xec' '\x30\xe6\x7b\x80' \
-            '\xe0\xf9\xa3\x22' '\xe4\xbc\x01\x60' \
-            '\x58\x68\xf7\x59' '\xd8\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xf2\x00\x18\xec' b'\x30\xe6\x7b\x80' \
+            b'\xe0\xf9\xa3\x22' b'\xe4\xbc\x01\x60' \
+            b'\x58\x68\xf7\x59' b'\xd8\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.GraphicsExpose._fields.to_binary, (), self.evt_args_0)
+        bin = event.GraphicsExpose._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -176,14 +178,14 @@
             'window': 1319843810,
             'minor_event': 45687,
             }
-        self.evt_bin_0 = '\xbb\x00\xb4\x5b' '\x4e\xab\x37\xe2' \
-            '\xb2\x77\xf2\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xbb\x00\xb4\x5b' b'\x4e\xab\x37\xe2' \
+            b'\xb2\x77\xf2\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.NoExpose._fields.to_binary, (), self.evt_args_0)
+        bin = event.NoExpose._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -209,14 +211,14 @@
             'type': 242,
             'window': 1543431298,
             }
-        self.evt_bin_0 = '\xf2\x00\xce\x45' '\x5b\xfe\xe4\x82' \
-            '\xee\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xf2\x00\xce\x45' b'\x5b\xfe\xe4\x82' \
+            b'\xee\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.VisibilityNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.VisibilityNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -248,14 +250,14 @@
             'window': 8505372,
             'width': 8871,
             }
-        self.evt_bin_0 = '\xff\x00\x20\x3d' '\x27\x00\x3a\x54' \
-            '\x00\x81\xc8\x1c' '\x86\x1c\xa2\x9c' \
-            '\x22\xa7\x3c\x92' '\xd0\xa6\x01\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xff\x00\x20\x3d' b'\x27\x00\x3a\x54' \
+            b'\x00\x81\xc8\x1c' b'\x86\x1c\xa2\x9c' \
+            b'\x22\xa7\x3c\x92' b'\xd0\xa6\x01\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.CreateNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.CreateNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -281,14 +283,14 @@
             'type': 223,
             'window': 1716558237,
             }
-        self.evt_bin_0 = '\xdf\x00\xbf\xf1' '\x18\x56\x02\x91' \
-            '\x66\x50\x99\x9d' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xdf\x00\xbf\xf1' b'\x18\x56\x02\x91' \
+            b'\x66\x50\x99\x9d' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.DestroyNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.DestroyNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -315,14 +317,14 @@
             'type': 217,
             'window': 1455493798,
             }
-        self.evt_bin_0 = '\xd9\x00\x11\x3c' '\x42\xe1\xef\x20' \
-            '\x56\xc1\x12\xa6' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xd9\x00\x11\x3c' b'\x42\xe1\xef\x20' \
+            b'\x56\xc1\x12\xa6' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.UnmapNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.UnmapNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -349,14 +351,14 @@
             'window': 1882369959,
             'override': 0,
             }
-        self.evt_bin_0 = '\xe4\x00\xfe\x48' '\x13\x96\x31\xdc' \
-            '\x70\x32\xaf\xa7' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xe4\x00\xfe\x48' b'\x13\x96\x31\xdc' \
+            b'\x70\x32\xaf\xa7' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.MapNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.MapNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -382,14 +384,14 @@
             'type': 171,
             'window': 488763730,
             }
-        self.evt_bin_0 = '\xab\x00\xc9\x60' '\x63\x32\x36\x90' \
-            '\x1d\x21\xf1\x52' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xab\x00\xc9\x60' b'\x63\x32\x36\x90' \
+            b'\x1d\x21\xf1\x52' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.MapRequest._fields.to_binary, (), self.evt_args_0)
+        bin = event.MapRequest._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -419,14 +421,14 @@
             'parent': 912114770,
             'window': 1142506827,
             }
-        self.evt_bin_0 = '\xe5\x00\x24\x28' '\x77\x39\xbd\xd5' \
-            '\x44\x19\x45\x4b' '\x36\x5d\xc4\x52' \
-            '\x90\x55\xd2\xb3' '\x01\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xe5\x00\x24\x28' b'\x77\x39\xbd\xd5' \
+            b'\x44\x19\x45\x4b' b'\x36\x5d\xc4\x52' \
+            b'\x90\x55\xd2\xb3' b'\x01\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.ReparentNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.ReparentNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -459,14 +461,14 @@
             'window': 2046157981,
             'width': 8604,
             }
-        self.evt_bin_0 = '\xbf\x00\xf3\x9c' '\x51\xdd\x44\x66' \
-            '\x79\xf5\xe4\x9d' '\x41\x8b\x95\xa2' \
-            '\xce\x1d\xc4\x84' '\x21\x9c\x3f\x73' \
-            '\x1c\x4c\x01\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xbf\x00\xf3\x9c' b'\x51\xdd\x44\x66' \
+            b'\x79\xf5\xe4\x9d' b'\x41\x8b\x95\xa2' \
+            b'\xce\x1d\xc4\x84' b'\x21\x9c\x3f\x73' \
+            b'\x1c\x4c\x01\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.ConfigureNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.ConfigureNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -500,14 +502,14 @@
             'stack_mode': 199,
             'parent': 176713389,
             }
-        self.evt_bin_0 = '\x9c\xc7\x7a\x91' '\x0a\x88\x6e\xad' \
-            '\x49\x60\x48\x53' '\x44\xd3\x8b\x96' \
-            '\xb8\xf1\xbb\x01' '\xc9\xa4\xb7\xf6' \
-            '\xd5\xfb\x4b\x91' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\x9c\xc7\x7a\x91' b'\x0a\x88\x6e\xad' \
+            b'\x49\x60\x48\x53' b'\x44\xd3\x8b\x96' \
+            b'\xb8\xf1\xbb\x01' b'\xc9\xa4\xb7\xf6' \
+            b'\xd5\xfb\x4b\x91' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.ConfigureRequest._fields.to_binary, (), self.evt_args_0)
+        bin = event.ConfigureRequest._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -535,14 +537,14 @@
             'x': -21924,
             'y': -4866,
             }
-        self.evt_bin_0 = '\xc0\x00\xa9\x70' '\x26\x3d\x12\xa5' \
-            '\x03\x14\xd8\x1a' '\xaa\x5c\xec\xfe' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xc0\x00\xa9\x70' b'\x26\x3d\x12\xa5' \
+            b'\x03\x14\xd8\x1a' b'\xaa\x5c\xec\xfe' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.GravityNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.GravityNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -569,14 +571,14 @@
             'window': 1698104652,
             'width': 41494,
             }
-        self.evt_bin_0 = '\x95\x00\x53\x64' '\x65\x37\x05\x4c' \
-            '\xa2\x16\xe9\x68' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\x95\x00\x53\x64' b'\x65\x37\x05\x4c' \
+            b'\xa2\x16\xe9\x68' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.ResizeRequest._fields.to_binary, (), self.evt_args_0)
+        bin = event.ResizeRequest._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -604,14 +606,14 @@
             'state': 181,
             'window': 334365400,
             }
-        self.evt_bin_0 = '\xbc\x00\x73\xe6' '\x13\xee\x02\xd8' \
-            '\x2d\x74\x24\x38' '\x6a\xc2\x4b\x25' \
-            '\xb5\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xbc\x00\x73\xe6' b'\x13\xee\x02\xd8' \
+            b'\x2d\x74\x24\x38' b'\x6a\xc2\x4b\x25' \
+            b'\xb5\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.PropertyNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.PropertyNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -638,14 +640,14 @@
             'type': 170,
             'window': 355039782,
             }
-        self.evt_bin_0 = '\xaa\x00\x35\x7b' '\x22\x74\xca\x43' \
-            '\x15\x29\x7a\x26' '\x52\x94\x54\x73' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xaa\x00\x35\x7b' b'\x22\x74\xca\x43' \
+            b'\x15\x29\x7a\x26' b'\x52\x94\x54\x73' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.SelectionClear._fields.to_binary, (), self.evt_args_0)
+        bin = event.SelectionClear._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -675,14 +677,14 @@
             'selection': 1972323175,
             'requestor': 178195168,
             }
-        self.evt_bin_0 = '\xa2\x00\x33\xc6' '\x44\xd2\x57\x9a' \
-            '\x7b\xba\xc5\x57' '\x0a\x9f\x0a\xe0' \
-            '\x75\x8f\x43\x67' '\x4e\x3b\xb0\x83' \
-            '\x17\xac\x30\xe9' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xa2\x00\x33\xc6' b'\x44\xd2\x57\x9a' \
+            b'\x7b\xba\xc5\x57' b'\x0a\x9f\x0a\xe0' \
+            b'\x75\x8f\x43\x67' b'\x4e\x3b\xb0\x83' \
+            b'\x17\xac\x30\xe9' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.SelectionRequest._fields.to_binary, (), self.evt_args_0)
+        bin = event.SelectionRequest._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -711,14 +713,14 @@
             'selection': 781895626,
             'requestor': 1242076588,
             }
-        self.evt_bin_0 = '\xc7\x00\x9b\x38' '\x34\x95\x2f\x5e' \
-            '\x4a\x08\x95\xac' '\x2e\x9a\xc7\xca' \
-            '\x7f\x0b\x8a\x2d' '\x12\x05\xd7\x93' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xc7\x00\x9b\x38' b'\x34\x95\x2f\x5e' \
+            b'\x4a\x08\x95\xac' b'\x2e\x9a\xc7\xca' \
+            b'\x7f\x0b\x8a\x2d' b'\x12\x05\xd7\x93' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.SelectionNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.SelectionNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -746,14 +748,14 @@
             'window': 1591667531,
             'new': 1,
             }
-        self.evt_bin_0 = '\xe9\x00\xf5\xb6' '\x5e\xde\xeb\x4b' \
-            '\x11\xed\xd7\x06' '\x01\xd1\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xe9\x00\xf5\xb6' b'\x5e\xde\xeb\x4b' \
+            b'\x11\xed\xd7\x06' b'\x01\xd1\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.ColormapNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.ColormapNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -780,10 +782,10 @@
             'client_type': 1340394836,
             'window': 1256861040,
             }
-        self.evt_bin_0 = '\xf5\x08\xbe\x48' '\x4a\xea\x2d\x70' \
-            '\x4f\xe4\xcd\x54' '\x30\x31\x32\x33' \
-            '\x34\x35\x36\x37' '\x38\x39\x30\x31' \
-            '\x32\x33\x34\x35' '\x36\x37\x38\x39'
+        self.evt_bin_0 = b'\xf5\x08\xbe\x48' b'\x4a\xea\x2d\x70' \
+            b'\x4f\xe4\xcd\x54' b'\x30\x31\x32\x33' \
+            b'\x34\x35\x36\x37' b'\x38\x39\x30\x31' \
+            b'\x32\x33\x34\x35' b'\x36\x37\x38\x39'
 
         self.evt_args_1 = {
             'sequence_number': 62804,
@@ -792,10 +794,10 @@
             'client_type': 214585025,
             'window': 151327338,
             }
-        self.evt_bin_1 = '\xfa\x10\xf5\x54' '\x09\x05\x12\x6a' \
-            '\x0c\xca\x4e\xc1' '\x00\x01\x00\x02' \
-            '\x00\x03\x00\x04' '\x00\x05\x00\x06' \
-            '\x00\x07\x00\x08' '\x00\x09\x00\x0a'
+        self.evt_bin_1 = b'\xfa\x10\xf5\x54' b'\x09\x05\x12\x6a' \
+            b'\x0c\xca\x4e\xc1' b'\x00\x01\x00\x02' \
+            b'\x00\x03\x00\x04' b'\x00\x05\x00\x06' \
+            b'\x00\x07\x00\x08' b'\x00\x09\x00\x0a'
 
         self.evt_args_2 = {
             'sequence_number': 3122,
@@ -804,14 +806,14 @@
             'client_type': 698151018,
             'window': 725159371,
             }
-        self.evt_bin_2 = '\xf3\x20\x0c\x32' '\x2b\x39\x0d\xcb' \
-            '\x29\x9c\xf0\x6a' '\x00\x00\x00\x01' \
-            '\x00\x00\x00\x02' '\x00\x00\x00\x03' \
-            '\x00\x00\x00\x04' '\x00\x00\x00\x05'
+        self.evt_bin_2 = b'\xf3\x20\x0c\x32' b'\x2b\x39\x0d\xcb' \
+            b'\x29\x9c\xf0\x6a' b'\x00\x00\x00\x01' \
+            b'\x00\x00\x00\x02' b'\x00\x00\x00\x03' \
+            b'\x00\x00\x00\x04' b'\x00\x00\x00\x05'
 
 
     def testPack0(self):
-        bin = apply(event.ClientMessage._fields.to_binary, (), self.evt_args_0)
+        bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -829,7 +831,7 @@
             raise AssertionError(args)
 
     def testPack1(self):
-        bin = apply(event.ClientMessage._fields.to_binary, (), self.evt_args_1)
+        bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_1)
         try:
             assert bin == self.evt_bin_1
         except AssertionError:
@@ -847,7 +849,7 @@
             raise AssertionError(args)
 
     def testPack2(self):
-        bin = apply(event.ClientMessage._fields.to_binary, (), self.evt_args_2)
+        bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_2)
         try:
             assert bin == self.evt_bin_2
         except AssertionError:
@@ -874,14 +876,14 @@
             'type': 252,
             'first_keycode': 218,
             }
-        self.evt_bin_0 = '\xfc\x00\xd1\x25' '\x8d\xda\x97\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xfc\x00\xd1\x25' b'\x8d\xda\x97\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.MappingNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.MappingNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
Index: python-xlib-0.14+20091101/test/test_events_le.py
===================================================================
--- python-xlib-0.14+20091101.orig/test/test_events_le.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/test/test_events_le.py	2013-10-11 14:19:21.101971349 -0400
@@ -3,7 +3,6 @@
 import sys, os
 sys.path.insert(1, os.path.join(sys.path[0], '..'))
 
-import string
 import unittest
 from Xlib.protocol import request, rq, event
 import Xlib.protocol.event
@@ -13,7 +12,7 @@
 
 class CmpArray:
     def __init__(self, *args, **kws):
-        self.array = apply(array.array, args, kws)
+        self.array = array.array(*args, **kws)
 
     def __len__(self):
         return len(self.array)
@@ -24,13 +23,16 @@
     def __getattr__(self, attr):
         return getattr(self.array, attr)
 
-    def __cmp__(self, other):
-        return cmp(self.array.tolist(), other)
+    def __eq__(self, other):
+        return self.array.tolist() == other
+
+    def __ne__(self, other):
+        return self.array.tolist() != other
 
 rq.array = CmpArray
 
 def tohex(bin):
-    bin = string.join(map(lambda c: '\\x%02x' % ord(c), bin), '')
+    bin = ''.join(map(lambda c: '\\x%02x' % c, bin))
 
     bins = []
     for i in range(0, len(bin), 16):
@@ -43,7 +45,7 @@
         except IndexError:
             bins2.append("'%s'" % bins[i])
 
-    return string.join(bins2, ' \\\n            ')
+    return ' \\\n            '.join(bins2)
 
 class DummyDisplay:
     def get_resource_class(self, x):
@@ -66,14 +68,14 @@
             'type': 173,
             'data': [130, 181, 177, 244, 167, 144, 216, 185, 228, 220, 254, 130, 239, 213, 142, 240, 233, 248, 161, 238, 160, 205, 212, 205, 166, 156, 241, 169, 198, 147, 144],
             }
-        self.evt_bin_0 = '\xad\x82\xb5\xb1' '\xf4\xa7\x90\xd8' \
-            '\xb9\xe4\xdc\xfe' '\x82\xef\xd5\x8e' \
-            '\xf0\xe9\xf8\xa1' '\xee\xa0\xcd\xd4' \
-            '\xcd\xa6\x9c\xf1' '\xa9\xc6\x93\x90'
+        self.evt_bin_0 = b'\xad\x82\xb5\xb1' b'\xf4\xa7\x90\xd8' \
+            b'\xb9\xe4\xdc\xfe' b'\x82\xef\xd5\x8e' \
+            b'\xf0\xe9\xf8\xa1' b'\xee\xa0\xcd\xd4' \
+            b'\xcd\xa6\x9c\xf1' b'\xa9\xc6\x93\x90'
 
 
     def testPack0(self):
-        bin = apply(event.KeymapNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.KeymapNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -103,14 +105,14 @@
             'sequence_number': 45668,
             'height': 29709,
             }
-        self.evt_bin_0 = '\xc0\x00\x64\xb2' '\xb0\x95\xcc\x76' \
-            '\x24\x3d\xe2\x71' '\xc0\xde\x0d\x74' \
-            '\x57\x79\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xc0\x00\x64\xb2' b'\xb0\x95\xcc\x76' \
+            b'\x24\x3d\xe2\x71' b'\xc0\xde\x0d\x74' \
+            b'\x57\x79\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.Expose._fields.to_binary, (), self.evt_args_0)
+        bin = event.Expose._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -142,14 +144,14 @@
             'sequence_number': 9516,
             'height': 10465,
             }
-        self.evt_bin_0 = '\x8a\x00\x2c\x25' '\xb1\xf4\xa7\x38' \
-            '\x79\xc3\x6c\x09' '\x92\x54\xe1\x28' \
-            '\x50\xad\x5a\x1b' '\xee\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\x8a\x00\x2c\x25' b'\xb1\xf4\xa7\x38' \
+            b'\x79\xc3\x6c\x09' b'\x92\x54\xe1\x28' \
+            b'\x50\xad\x5a\x1b' b'\xee\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.GraphicsExpose._fields.to_binary, (), self.evt_args_0)
+        bin = event.GraphicsExpose._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -176,14 +178,14 @@
             'major_event': 149,
             'sequence_number': 51301,
             }
-        self.evt_bin_0 = '\xc6\x00\x65\xc8' '\x22\x92\xd6\x52' \
-            '\xa2\xbf\x95\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xc6\x00\x65\xc8' b'\x22\x92\xd6\x52' \
+            b'\xa2\xbf\x95\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.NoExpose._fields.to_binary, (), self.evt_args_0)
+        bin = event.NoExpose._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -209,14 +211,14 @@
             'state': 239,
             'sequence_number': 38248,
             }
-        self.evt_bin_0 = '\xe9\x00\x68\x95' '\x72\xac\x93\x32' \
-            '\xef\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xe9\x00\x68\x95' b'\x72\xac\x93\x32' \
+            b'\xef\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.VisibilityNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.VisibilityNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -248,14 +250,14 @@
             'sequence_number': 14268,
             'height': 8803,
             }
-        self.evt_bin_0 = '\xe6\x00\xbc\x37' '\x55\x6b\xb4\x06' \
-            '\x58\x8e\x2b\x4f' '\x94\xca\x74\x85' \
-            '\xef\x5f\x63\x22' '\x2c\x80\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xe6\x00\xbc\x37' b'\x55\x6b\xb4\x06' \
+            b'\x58\x8e\x2b\x4f' b'\x94\xca\x74\x85' \
+            b'\xef\x5f\x63\x22' b'\x2c\x80\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.CreateNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.CreateNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -281,14 +283,14 @@
             'event': 1596763581,
             'sequence_number': 37839,
             }
-        self.evt_bin_0 = '\xb7\x00\xcf\x93' '\xbd\xad\x2c\x5f' \
-            '\x39\xd4\x86\x52' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xb7\x00\xcf\x93' b'\xbd\xad\x2c\x5f' \
+            b'\x39\xd4\x86\x52' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.DestroyNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.DestroyNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -315,14 +317,14 @@
             'sequence_number': 55135,
             'from_configure': 0,
             }
-        self.evt_bin_0 = '\xc0\x00\x5f\xd7' '\x1a\x88\x73\x36' \
-            '\xf4\xb1\x87\x4b' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xc0\x00\x5f\xd7' b'\x1a\x88\x73\x36' \
+            b'\xf4\xb1\x87\x4b' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.UnmapNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.UnmapNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -349,14 +351,14 @@
             'event': 1566597012,
             'sequence_number': 8920,
             }
-        self.evt_bin_0 = '\xd8\x00\xd8\x22' '\x94\x5f\x60\x5d' \
-            '\xe8\xb1\x5a\x77' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xd8\x00\xd8\x22' b'\x94\x5f\x60\x5d' \
+            b'\xe8\xb1\x5a\x77' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.MapNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.MapNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -382,14 +384,14 @@
             'parent': 1188866605,
             'sequence_number': 6729,
             }
-        self.evt_bin_0 = '\xf2\x00\x49\x1a' '\x2d\xaa\xdc\x46' \
-            '\x4d\x6b\xba\x67' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xf2\x00\x49\x1a' b'\x2d\xaa\xdc\x46' \
+            b'\x4d\x6b\xba\x67' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.MapRequest._fields.to_binary, (), self.evt_args_0)
+        bin = event.MapRequest._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -419,14 +421,14 @@
             'event': 1344092894,
             'sequence_number': 31034,
             }
-        self.evt_bin_0 = '\xb9\x00\x3a\x79' '\xde\x3a\x1d\x50' \
-            '\xff\xf9\xc4\x36' '\x1e\x3e\x65\x3e' \
-            '\xda\xd1\xfd\xd5' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xb9\x00\x3a\x79' b'\xde\x3a\x1d\x50' \
+            b'\xff\xf9\xc4\x36' b'\x1e\x3e\x65\x3e' \
+            b'\xda\xd1\xfd\xd5' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.ReparentNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.ReparentNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -459,14 +461,14 @@
             'event': 2102634753,
             'sequence_number': 21818,
             }
-        self.evt_bin_0 = '\xbf\x00\x3a\x55' '\x01\xa9\x53\x7d' \
-            '\xe9\xba\x4c\x65' '\x29\x26\x2f\x44' \
-            '\x5f\xa3\xb9\x80' '\x7f\x5e\x4d\xad' \
-            '\x55\xca\x01\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xbf\x00\x3a\x55' b'\x01\xa9\x53\x7d' \
+            b'\xe9\xba\x4c\x65' b'\x29\x26\x2f\x44' \
+            b'\x5f\xa3\xb9\x80' b'\x7f\x5e\x4d\xad' \
+            b'\x55\xca\x01\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.ConfigureNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.ConfigureNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -500,14 +502,14 @@
             'type': 140,
             'sequence_number': 48820,
             }
-        self.evt_bin_0 = '\x8c\x9b\xb4\xbe' '\xfc\xc8\x80\x58' \
-            '\xdd\x64\xbd\x20' '\xfe\xe2\xc1\x44' \
-            '\xfc\xd2\x05\xfc' '\x4a\xb6\x90\x6a' \
-            '\x53\xa1\x1b\xa3' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\x8c\x9b\xb4\xbe' b'\xfc\xc8\x80\x58' \
+            b'\xdd\x64\xbd\x20' b'\xfe\xe2\xc1\x44' \
+            b'\xfc\xd2\x05\xfc' b'\x4a\xb6\x90\x6a' \
+            b'\x53\xa1\x1b\xa3' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.ConfigureRequest._fields.to_binary, (), self.evt_args_0)
+        bin = event.ConfigureRequest._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -535,14 +537,14 @@
             'event': 860169186,
             'sequence_number': 48472,
             }
-        self.evt_bin_0 = '\xbf\x00\x58\xbd' '\xe2\x23\x45\x33' \
-            '\x38\x1b\xb0\x57' '\x7e\xd5\x27\x97' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xbf\x00\x58\xbd' b'\xe2\x23\x45\x33' \
+            b'\x38\x1b\xb0\x57' b'\x7e\xd5\x27\x97' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.GravityNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.GravityNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -569,14 +571,14 @@
             'sequence_number': 9443,
             'height': 58942,
             }
-        self.evt_bin_0 = '\x8b\x00\xe3\x24' '\x73\xcf\x4f\x3b' \
-            '\x8a\x22\x3e\xe6' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\x8b\x00\xe3\x24' b'\x73\xcf\x4f\x3b' \
+            b'\x8a\x22\x3e\xe6' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.ResizeRequest._fields.to_binary, (), self.evt_args_0)
+        bin = event.ResizeRequest._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -604,14 +606,14 @@
             'state': 241,
             'sequence_number': 47586,
             }
-        self.evt_bin_0 = '\xcd\x00\xe2\xb9' '\xbe\x45\x1b\x69' \
-            '\x60\x2c\xd0\x02' '\xca\x79\xd2\x37' \
-            '\xf1\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xcd\x00\xe2\xb9' b'\xbe\x45\x1b\x69' \
+            b'\x60\x2c\xd0\x02' b'\xca\x79\xd2\x37' \
+            b'\xf1\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.PropertyNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.PropertyNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -638,14 +640,14 @@
             'sequence_number': 26660,
             'time': 1732839301,
             }
-        self.evt_bin_0 = '\xe8\x00\x24\x68' '\x85\x07\x49\x67' \
-            '\x51\x65\x0b\x14' '\xff\x27\x49\x0f' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xe8\x00\x24\x68' b'\x85\x07\x49\x67' \
+            b'\x51\x65\x0b\x14' b'\xff\x27\x49\x0f' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.SelectionClear._fields.to_binary, (), self.evt_args_0)
+        bin = event.SelectionClear._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -675,14 +677,14 @@
             'type': 147,
             'sequence_number': 20571,
             }
-        self.evt_bin_0 = '\x93\x00\x5b\x50' '\xe9\x35\xda\x54' \
-            '\xf3\x3e\x97\x2d' '\x41\xc6\xca\x0f' \
-            '\xc0\x1f\x8c\x5b' '\x07\xdb\x38\x24' \
-            '\x26\x99\x6e\x44' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\x93\x00\x5b\x50' b'\xe9\x35\xda\x54' \
+            b'\xf3\x3e\x97\x2d' b'\x41\xc6\xca\x0f' \
+            b'\xc0\x1f\x8c\x5b' b'\x07\xdb\x38\x24' \
+            b'\x26\x99\x6e\x44' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.SelectionRequest._fields.to_binary, (), self.evt_args_0)
+        bin = event.SelectionRequest._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -711,14 +713,14 @@
             'type': 133,
             'sequence_number': 30741,
             }
-        self.evt_bin_0 = '\x85\x00\x15\x78' '\xab\x44\xee\x3c' \
-            '\xb1\x59\xe8\x39' '\x06\x6d\x83\x13' \
-            '\xd1\xfe\xb7\x6f' '\xbe\x02\xcd\x6a' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\x85\x00\x15\x78' b'\xab\x44\xee\x3c' \
+            b'\xb1\x59\xe8\x39' b'\x06\x6d\x83\x13' \
+            b'\xd1\xfe\xb7\x6f' b'\xbe\x02\xcd\x6a' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.SelectionNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.SelectionNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -746,14 +748,14 @@
             'state': 168,
             'sequence_number': 8684,
             }
-        self.evt_bin_0 = '\xd3\x00\xec\x21' '\xbb\x4b\xb1\x50' \
-            '\x9d\xab\x52\x27' '\x01\xa8\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xd3\x00\xec\x21' b'\xbb\x4b\xb1\x50' \
+            b'\x9d\xab\x52\x27' b'\x01\xa8\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.ColormapNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.ColormapNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -780,10 +782,10 @@
             'data': (8, '01234567890123456789'),
             'sequence_number': 14854,
             }
-        self.evt_bin_0 = '\xed\x08\x06\x3a' '\x82\xab\x90\x6b' \
-            '\x49\x39\x23\x1b' '\x30\x31\x32\x33' \
-            '\x34\x35\x36\x37' '\x38\x39\x30\x31' \
-            '\x32\x33\x34\x35' '\x36\x37\x38\x39'
+        self.evt_bin_0 = b'\xed\x08\x06\x3a' b'\x82\xab\x90\x6b' \
+            b'\x49\x39\x23\x1b' b'\x30\x31\x32\x33' \
+            b'\x34\x35\x36\x37' b'\x38\x39\x30\x31' \
+            b'\x32\x33\x34\x35' b'\x36\x37\x38\x39'
 
         self.evt_args_1 = {
             'type': 160,
@@ -792,10 +794,10 @@
             'data': (16, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),
             'sequence_number': 28171,
             }
-        self.evt_bin_1 = '\xa0\x10\x0b\x6e' '\x3e\xb2\x8e\x38' \
-            '\xac\x66\xa7\x0c' '\x01\x00\x02\x00' \
-            '\x03\x00\x04\x00' '\x05\x00\x06\x00' \
-            '\x07\x00\x08\x00' '\x09\x00\x0a\x00'
+        self.evt_bin_1 = b'\xa0\x10\x0b\x6e' b'\x3e\xb2\x8e\x38' \
+            b'\xac\x66\xa7\x0c' b'\x01\x00\x02\x00' \
+            b'\x03\x00\x04\x00' b'\x05\x00\x06\x00' \
+            b'\x07\x00\x08\x00' b'\x09\x00\x0a\x00'
 
         self.evt_args_2 = {
             'type': 243,
@@ -804,14 +806,14 @@
             'data': (32, [1, 2, 3, 4, 5]),
             'sequence_number': 63569,
             }
-        self.evt_bin_2 = '\xf3\x20\x51\xf8' '\x46\x88\xaf\x22' \
-            '\xfe\x65\xa1\x39' '\x01\x00\x00\x00' \
-            '\x02\x00\x00\x00' '\x03\x00\x00\x00' \
-            '\x04\x00\x00\x00' '\x05\x00\x00\x00'
+        self.evt_bin_2 = b'\xf3\x20\x51\xf8' b'\x46\x88\xaf\x22' \
+            b'\xfe\x65\xa1\x39' b'\x01\x00\x00\x00' \
+            b'\x02\x00\x00\x00' b'\x03\x00\x00\x00' \
+            b'\x04\x00\x00\x00' b'\x05\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.ClientMessage._fields.to_binary, (), self.evt_args_0)
+        bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
@@ -829,7 +831,7 @@
             raise AssertionError(args)
 
     def testPack1(self):
-        bin = apply(event.ClientMessage._fields.to_binary, (), self.evt_args_1)
+        bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_1)
         try:
             assert bin == self.evt_bin_1
         except AssertionError:
@@ -847,7 +849,7 @@
             raise AssertionError(args)
 
     def testPack2(self):
-        bin = apply(event.ClientMessage._fields.to_binary, (), self.evt_args_2)
+        bin = event.ClientMessage._fields.to_binary(*(), **self.evt_args_2)
         try:
             assert bin == self.evt_bin_2
         except AssertionError:
@@ -874,14 +876,14 @@
             'count': 201,
             'sequence_number': 32665,
             }
-        self.evt_bin_0 = '\xc6\x00\x99\x7f' '\xbd\xf6\xc9\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.evt_bin_0 = b'\xc6\x00\x99\x7f' b'\xbd\xf6\xc9\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPack0(self):
-        bin = apply(event.MappingNotify._fields.to_binary, (), self.evt_args_0)
+        bin = event.MappingNotify._fields.to_binary(*(), **self.evt_args_0)
         try:
             assert bin == self.evt_bin_0
         except AssertionError:
Index: python-xlib-0.14+20091101/test/test_requests_be.py
===================================================================
--- python-xlib-0.14+20091101.orig/test/test_requests_be.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/test/test_requests_be.py	2013-10-11 14:19:21.105971349 -0400
@@ -3,7 +3,6 @@
 import sys, os
 sys.path.insert(1, os.path.join(sys.path[0], '..'))
 
-import string
 import unittest
 from Xlib.protocol import request, rq, event
 import Xlib.protocol.event
@@ -13,7 +12,7 @@
 
 class CmpArray:
     def __init__(self, *args, **kws):
-        self.array = apply(array.array, args, kws)
+        self.array = array.array(*args, **kws)
 
     def __len__(self):
         return len(self.array)
@@ -21,16 +20,25 @@
     def __getslice__(self, x, y):
         return list(self.array[x:y])
 
+    def __getitem__(self, n):
+        if isinstance(n, slice):
+            return list(self.array.__getitem__(n))
+        else:
+            return self.array[n]
+
     def __getattr__(self, attr):
         return getattr(self.array, attr)
 
-    def __cmp__(self, other):
-        return cmp(self.array.tolist(), other)
+    def __eq__(self, other):
+        return self.array.tolist() == other
+
+    def __ne__(self, other):
+        return self.array.tolist() != other
 
 rq.array = CmpArray
 
 def tohex(bin):
-    bin = string.join(map(lambda c: '\\x%02x' % ord(c), bin), '')
+    bin = ''.join(map(lambda c: '\\x%02x' % c, bin))
 
     bins = []
     for i in range(0, len(bin), 16):
@@ -43,7 +51,7 @@
         except IndexError:
             bins2.append("'%s'" % bins[i])
 
-    return string.join(bins2, ' \\\n            ')
+    return ' \\\n            '.join(bins2)
 
 class DummyDisplay:
     def get_resource_class(self, x):
@@ -75,22 +83,22 @@
             'depth': 186,
             'width': 51466,
             }
-        self.req_bin_0 = '\x01\xba\x00\x17' '\x6d\x03\x01\x24' \
-            '\x74\xdb\x41\x4e' '\xae\xdd\xf0\x2f' \
-            '\xc9\x0a\x96\xd0' '\x86\x93\x00\x00' \
-            '\x17\xba\x10\x13' '\x00\x00\x7f\xff' \
-            '\x5e\x67\x63\x43' '\x0c\x77\x07\x07' \
-            '\x76\xc4\x0c\xaa' '\x7f\x48\x9d\x8c' \
-            '\x00\x00\x00\x00' '\x03\x00\x00\x00' \
-            '\x02\x00\x00\x00' '\x56\xac\x9b\x9d' \
-            '\x21\x76\x49\x57' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x15\xf2\xee\x1c' \
-            '\x23\x97\xad\x71' '\x16\x7e\xec\x01' \
-            '\x55\xfd\xbc\xc5'
+        self.req_bin_0 = b'\x01\xba\x00\x17' b'\x6d\x03\x01\x24' \
+            b'\x74\xdb\x41\x4e' b'\xae\xdd\xf0\x2f' \
+            b'\xc9\x0a\x96\xd0' b'\x86\x93\x00\x00' \
+            b'\x17\xba\x10\x13' b'\x00\x00\x7f\xff' \
+            b'\x5e\x67\x63\x43' b'\x0c\x77\x07\x07' \
+            b'\x76\xc4\x0c\xaa' b'\x7f\x48\x9d\x8c' \
+            b'\x00\x00\x00\x00' b'\x03\x00\x00\x00' \
+            b'\x02\x00\x00\x00' b'\x56\xac\x9b\x9d' \
+            b'\x21\x76\x49\x57' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x15\xf2\xee\x1c' \
+            b'\x23\x97\xad\x71' b'\x16\x7e\xec\x01' \
+            b'\x55\xfd\xbc\xc5'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CreateWindow._request.to_binary, (), self.req_args_0)
+        bin = request.CreateWindow._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -114,19 +122,19 @@
             'window': 1813552124,
             'attrs': {'backing_pixel': 59516078, 'cursor': 1682969315, 'background_pixmap': 370313360, 'border_pixmap': 1158771722, 'backing_planes': 1432315664, 'win_gravity': 3, 'backing_store': 1, 'event_mask': 1054128649, 'save_under': 0, 'background_pixel': 1953340842, 'colormap': 1462101672, 'border_pixel': 287436510, 'bit_gravity': 10, 'do_not_propagate_mask': 1283834625, 'override_redirect': 0},
             }
-        self.req_bin_0 = '\x02\x00\x00\x12' '\x6c\x18\x9b\xfc' \
-            '\x00\x00\x7f\xff' '\x16\x12\x88\x90' \
-            '\x74\x6d\x9d\xaa' '\x45\x11\x74\x0a' \
-            '\x11\x21\xee\xde' '\x0a\x00\x00\x00' \
-            '\x03\x00\x00\x00' '\x01\x00\x00\x00' \
-            '\x55\x5f\x67\x10' '\x03\x8c\x24\xae' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x3e\xd4\xba\x09' '\x4c\x85\xc3\x01' \
-            '\x57\x25\xe6\xa8' '\x64\x50\x12\xe3'
+        self.req_bin_0 = b'\x02\x00\x00\x12' b'\x6c\x18\x9b\xfc' \
+            b'\x00\x00\x7f\xff' b'\x16\x12\x88\x90' \
+            b'\x74\x6d\x9d\xaa' b'\x45\x11\x74\x0a' \
+            b'\x11\x21\xee\xde' b'\x0a\x00\x00\x00' \
+            b'\x03\x00\x00\x00' b'\x01\x00\x00\x00' \
+            b'\x55\x5f\x67\x10' b'\x03\x8c\x24\xae' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x3e\xd4\xba\x09' b'\x4c\x85\xc3\x01' \
+            b'\x57\x25\xe6\xa8' b'\x64\x50\x12\xe3'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangeWindowAttributes._request.to_binary, (), self.req_args_0)
+        bin = request.ChangeWindowAttributes._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -149,7 +157,7 @@
         self.req_args_0 = {
             'window': 1931593850,
             }
-        self.req_bin_0 = '\x03\x00\x00\x02' '\x73\x21\xc8\x7a'
+        self.req_bin_0 = b'\x03\x00\x00\x02' b'\x73\x21\xc8\x7a'
 
         self.reply_args_0 = {
             'sequence_number': 60057,
@@ -169,16 +177,16 @@
             'do_not_propagate_mask': 33787,
             'override_redirect': 0,
             }
-        self.reply_bin_0 = '\x01\x93\xea\x99' '\x00\x00\x00\x03' \
-            '\x28\xf8\xb5\x19' '\x47\x6c\xfd\x9d' \
-            '\x3b\x04\x67\x99' '\x08\x23\xc5\x49' \
-            '\x00\x00\xb9\x00' '\x45\x39\x51\x8e' \
-            '\x10\x1b\x49\x0c' '\x4f\x6a\xcc\x0f' \
-            '\x83\xfb\x00\x00'
+        self.reply_bin_0 = b'\x01\x93\xea\x99' b'\x00\x00\x00\x03' \
+            b'\x28\xf8\xb5\x19' b'\x47\x6c\xfd\x9d' \
+            b'\x3b\x04\x67\x99' b'\x08\x23\xc5\x49' \
+            b'\x00\x00\xb9\x00' b'\x45\x39\x51\x8e' \
+            b'\x10\x1b\x49\x0c' b'\x4f\x6a\xcc\x0f' \
+            b'\x83\xfb\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetWindowAttributes._request.to_binary, (), self.req_args_0)
+        bin = request.GetWindowAttributes._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -196,7 +204,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetWindowAttributes._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetWindowAttributes._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -219,11 +227,11 @@
         self.req_args_0 = {
             'window': 1622184267,
             }
-        self.req_bin_0 = '\x04\x00\x00\x02' '\x60\xb0\x91\x4b'
+        self.req_bin_0 = b'\x04\x00\x00\x02' b'\x60\xb0\x91\x4b'
 
 
     def testPackRequest0(self):
-        bin = apply(request.DestroyWindow._request.to_binary, (), self.req_args_0)
+        bin = request.DestroyWindow._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -246,11 +254,11 @@
         self.req_args_0 = {
             'window': 1000376476,
             }
-        self.req_bin_0 = '\x05\x00\x00\x02' '\x3b\xa0\x88\x9c'
+        self.req_bin_0 = b'\x05\x00\x00\x02' b'\x3b\xa0\x88\x9c'
 
 
     def testPackRequest0(self):
-        bin = apply(request.DestroySubWindows._request.to_binary, (), self.req_args_0)
+        bin = request.DestroySubWindows._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -274,11 +282,11 @@
             'window': 1577523459,
             'mode': 0,
             }
-        self.req_bin_0 = '\x06\x00\x00\x02' '\x5e\x07\x19\x03'
+        self.req_bin_0 = b'\x06\x00\x00\x02' b'\x5e\x07\x19\x03'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangeSaveSet._request.to_binary, (), self.req_args_0)
+        bin = request.ChangeSaveSet._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -304,12 +312,12 @@
             'x': -5207,
             'y': -22675,
             }
-        self.req_bin_0 = '\x07\x00\x00\x04' '\x4d\x87\xa0\xa0' \
-            '\x04\x4d\x83\x68' '\xeb\xa9\xa7\x6d'
+        self.req_bin_0 = b'\x07\x00\x00\x04' b'\x4d\x87\xa0\xa0' \
+            b'\x04\x4d\x83\x68' b'\xeb\xa9\xa7\x6d'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ReparentWindow._request.to_binary, (), self.req_args_0)
+        bin = request.ReparentWindow._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -332,11 +340,11 @@
         self.req_args_0 = {
             'window': 61469476,
             }
-        self.req_bin_0 = '\x08\x00\x00\x02' '\x03\xa9\xf3\x24'
+        self.req_bin_0 = b'\x08\x00\x00\x02' b'\x03\xa9\xf3\x24'
 
 
     def testPackRequest0(self):
-        bin = apply(request.MapWindow._request.to_binary, (), self.req_args_0)
+        bin = request.MapWindow._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -359,11 +367,11 @@
         self.req_args_0 = {
             'window': 818738118,
             }
-        self.req_bin_0 = '\x09\x00\x00\x02' '\x30\xcc\xf3\xc6'
+        self.req_bin_0 = b'\x09\x00\x00\x02' b'\x30\xcc\xf3\xc6'
 
 
     def testPackRequest0(self):
-        bin = apply(request.MapSubwindows._request.to_binary, (), self.req_args_0)
+        bin = request.MapSubwindows._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -386,11 +394,11 @@
         self.req_args_0 = {
             'window': 1923663468,
             }
-        self.req_bin_0 = '\x0a\x00\x00\x02' '\x72\xa8\xc6\x6c'
+        self.req_bin_0 = b'\x0a\x00\x00\x02' b'\x72\xa8\xc6\x6c'
 
 
     def testPackRequest0(self):
-        bin = apply(request.UnmapWindow._request.to_binary, (), self.req_args_0)
+        bin = request.UnmapWindow._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -413,11 +421,11 @@
         self.req_args_0 = {
             'window': 999740194,
             }
-        self.req_bin_0 = '\x0b\x00\x00\x02' '\x3b\x96\xd3\x22'
+        self.req_bin_0 = b'\x0b\x00\x00\x02' b'\x3b\x96\xd3\x22'
 
 
     def testPackRequest0(self):
-        bin = apply(request.UnmapSubwindows._request.to_binary, (), self.req_args_0)
+        bin = request.UnmapSubwindows._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -441,15 +449,15 @@
             'window': 190634459,
             'attrs': {'height': 57788, 'stack_mode': 2, 'border_width': -320, 'width': 53674, 'x': -2248, 'y': -29960, 'sibling': 1012823324},
             }
-        self.req_bin_0 = '\x0c\x00\x00\x0a' '\x0b\x5c\xd9\xdb' \
-            '\x00\x7f\x00\x00' '\xf7\x38\x00\x00' \
-            '\x8a\xf8\x00\x00' '\xd1\xaa\x00\x00' \
-            '\xe1\xbc\x00\x00' '\xfe\xc0\x00\x00' \
-            '\x3c\x5e\x75\x1c' '\x02\x00\x00\x00'
+        self.req_bin_0 = b'\x0c\x00\x00\x0a' b'\x0b\x5c\xd9\xdb' \
+            b'\x00\x7f\x00\x00' b'\xf7\x38\x00\x00' \
+            b'\x8a\xf8\x00\x00' b'\xd1\xaa\x00\x00' \
+            b'\xe1\xbc\x00\x00' b'\xfe\xc0\x00\x00' \
+            b'\x3c\x5e\x75\x1c' b'\x02\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ConfigureWindow._request.to_binary, (), self.req_args_0)
+        bin = request.ConfigureWindow._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -473,11 +481,11 @@
             'window': 1712979067,
             'direction': 1,
             }
-        self.req_bin_0 = '\x0d\x01\x00\x02' '\x66\x19\xfc\x7b'
+        self.req_bin_0 = b'\x0d\x01\x00\x02' b'\x66\x19\xfc\x7b'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CirculateWindow._request.to_binary, (), self.req_args_0)
+        bin = request.CirculateWindow._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -500,7 +508,7 @@
         self.req_args_0 = {
             'drawable': 680179490,
             }
-        self.req_bin_0 = '\x0e\x00\x00\x02' '\x28\x8a\xb7\x22'
+        self.req_bin_0 = b'\x0e\x00\x00\x02' b'\x28\x8a\xb7\x22'
 
         self.reply_args_0 = {
             'height': 64954,
@@ -512,14 +520,14 @@
             'depth': 204,
             'width': 38433,
             }
-        self.reply_bin_0 = '\x01\xcc\x9a\x2d' '\x00\x00\x00\x00' \
-            '\x24\x55\x8d\x71' '\xfb\x1b\xd4\x54' \
-            '\x96\x21\xfd\xba' '\x01\xf0\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\xcc\x9a\x2d' b'\x00\x00\x00\x00' \
+            b'\x24\x55\x8d\x71' b'\xfb\x1b\xd4\x54' \
+            b'\x96\x21\xfd\xba' b'\x01\xf0\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetGeometry._request.to_binary, (), self.req_args_0)
+        bin = request.GetGeometry._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -537,7 +545,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetGeometry._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetGeometry._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -560,7 +568,7 @@
         self.req_args_0 = {
             'window': 2052496265,
             }
-        self.req_bin_0 = '\x0f\x00\x00\x02' '\x7a\x56\x9b\x89'
+        self.req_bin_0 = b'\x0f\x00\x00\x02' b'\x7a\x56\x9b\x89'
 
         self.reply_args_0 = {
             'sequence_number': 33887,
@@ -568,18 +576,18 @@
             'root': 1856577120,
             'parent': 2105827407,
             }
-        self.reply_bin_0 = '\x01\x00\x84\x5f' '\x00\x00\x00\x07' \
-            '\x6e\xa9\x1e\x60' '\x7d\x84\x60\x4f' \
-            '\x00\x07\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x6b\x09\x3d\x72' '\x59\x14\x21\xa5' \
-            '\x2c\x9a\x2c\x42' '\x2b\x7b\x78\xa1' \
-            '\x4b\x39\x79\x79' '\x03\xd4\x32\x73' \
-            '\x40\xdd\x8e\x53'
+        self.reply_bin_0 = b'\x01\x00\x84\x5f' b'\x00\x00\x00\x07' \
+            b'\x6e\xa9\x1e\x60' b'\x7d\x84\x60\x4f' \
+            b'\x00\x07\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x6b\x09\x3d\x72' b'\x59\x14\x21\xa5' \
+            b'\x2c\x9a\x2c\x42' b'\x2b\x7b\x78\xa1' \
+            b'\x4b\x39\x79\x79' b'\x03\xd4\x32\x73' \
+            b'\x40\xdd\x8e\x53'
 
 
     def testPackRequest0(self):
-        bin = apply(request.QueryTree._request.to_binary, (), self.req_args_0)
+        bin = request.QueryTree._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -597,7 +605,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.QueryTree._reply.to_binary, (), self.reply_args_0)
+        bin = request.QueryTree._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -621,22 +629,22 @@
             'only_if_exists': 0,
             'name': 'fuzzy_prop',
             }
-        self.req_bin_0 = '\x10\x00\x00\x05' '\x00\x0a\x00\x00' \
-            '\x66\x75\x7a\x7a' '\x79\x5f\x70\x72' \
-            '\x6f\x70\x00\x00'
+        self.req_bin_0 = b'\x10\x00\x00\x05' b'\x00\x0a\x00\x00' \
+            b'\x66\x75\x7a\x7a' b'\x79\x5f\x70\x72' \
+            b'\x6f\x70\x00\x00'
 
         self.reply_args_0 = {
             'atom': 48723297,
             'sequence_number': 35223,
             }
-        self.reply_bin_0 = '\x01\x00\x89\x97' '\x00\x00\x00\x00' \
-            '\x02\xe7\x75\x61' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\x89\x97' b'\x00\x00\x00\x00' \
+            b'\x02\xe7\x75\x61' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.InternAtom._request.to_binary, (), self.req_args_0)
+        bin = request.InternAtom._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -654,7 +662,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.InternAtom._reply.to_binary, (), self.reply_args_0)
+        bin = request.InternAtom._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -677,21 +685,21 @@
         self.req_args_0 = {
             'atom': 1022286544,
             }
-        self.req_bin_0 = '\x11\x00\x00\x02' '\x3c\xee\xda\xd0'
+        self.req_bin_0 = b'\x11\x00\x00\x02' b'\x3c\xee\xda\xd0'
 
         self.reply_args_0 = {
             'sequence_number': 22699,
             'name': 'WM_CLASS',
             }
-        self.reply_bin_0 = '\x01\x00\x58\xab' '\x00\x00\x00\x02' \
-            '\x00\x08\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x57\x4d\x5f\x43' '\x4c\x41\x53\x53'
+        self.reply_bin_0 = b'\x01\x00\x58\xab' b'\x00\x00\x00\x02' \
+            b'\x00\x08\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x57\x4d\x5f\x43' b'\x4c\x41\x53\x53'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetAtomName._request.to_binary, (), self.req_args_0)
+        bin = request.GetAtomName._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -709,7 +717,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetAtomName._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetAtomName._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -736,9 +744,9 @@
             'window': 266197951,
             'type': 1343008022,
             }
-        self.req_bin_0 = '\x12\x00\x00\x06' '\x0f\xdd\xdb\xbf' \
-            '\x7c\x4c\x97\x11' '\x50\x0c\xad\x16' \
-            '\x08\x00\x00\x00' '\x00\x00\x00\x00'
+        self.req_bin_0 = b'\x12\x00\x00\x06' b'\x0f\xdd\xdb\xbf' \
+            b'\x7c\x4c\x97\x11' b'\x50\x0c\xad\x16' \
+            b'\x08\x00\x00\x00' b'\x00\x00\x00\x00'
 
         self.req_args_1 = {
             'mode': 2,
@@ -747,10 +755,10 @@
             'window': 1522118044,
             'type': 121096013,
             }
-        self.req_bin_1 = '\x12\x02\x00\x07' '\x5a\xb9\xad\x9c' \
-            '\x1a\xce\x2e\xab' '\x07\x37\xc7\x4d' \
-            '\x08\x00\x00\x00' '\x00\x00\x00\x03' \
-            '\x66\x6f\x6f\x00'
+        self.req_bin_1 = b'\x12\x02\x00\x07' b'\x5a\xb9\xad\x9c' \
+            b'\x1a\xce\x2e\xab' b'\x07\x37\xc7\x4d' \
+            b'\x08\x00\x00\x00' b'\x00\x00\x00\x03' \
+            b'\x66\x6f\x6f\x00'
 
         self.req_args_2 = {
             'mode': 2,
@@ -759,10 +767,10 @@
             'window': 286324270,
             'type': 1547457396,
             }
-        self.req_bin_2 = '\x12\x02\x00\x07' '\x11\x10\xf6\x2e' \
-            '\x3c\x30\xf5\x5a' '\x5c\x3c\x53\x74' \
-            '\x08\x00\x00\x00' '\x00\x00\x00\x04' \
-            '\x7a\x6f\x6f\x6d'
+        self.req_bin_2 = b'\x12\x02\x00\x07' b'\x11\x10\xf6\x2e' \
+            b'\x3c\x30\xf5\x5a' b'\x5c\x3c\x53\x74' \
+            b'\x08\x00\x00\x00' b'\x00\x00\x00\x04' \
+            b'\x7a\x6f\x6f\x6d'
 
         self.req_args_3 = {
             'mode': 0,
@@ -771,9 +779,9 @@
             'window': 1964921608,
             'type': 692879036,
             }
-        self.req_bin_3 = '\x12\x00\x00\x06' '\x75\x1e\x53\x08' \
-            '\x19\x73\x3e\xc0' '\x29\x4c\x7e\xbc' \
-            '\x10\x00\x00\x00' '\x00\x00\x00\x00'
+        self.req_bin_3 = b'\x12\x00\x00\x06' b'\x75\x1e\x53\x08' \
+            b'\x19\x73\x3e\xc0' b'\x29\x4c\x7e\xbc' \
+            b'\x10\x00\x00\x00' b'\x00\x00\x00\x00'
 
         self.req_args_4 = {
             'mode': 0,
@@ -782,10 +790,10 @@
             'window': 560040176,
             'type': 2030208993,
             }
-        self.req_bin_4 = '\x12\x00\x00\x08' '\x21\x61\x88\xf0' \
-            '\x2f\xbe\x64\xa4' '\x79\x02\x87\xe1' \
-            '\x10\x00\x00\x00' '\x00\x00\x00\x03' \
-            '\x00\x01\x00\x02' '\x00\x03\x00\x00'
+        self.req_bin_4 = b'\x12\x00\x00\x08' b'\x21\x61\x88\xf0' \
+            b'\x2f\xbe\x64\xa4' b'\x79\x02\x87\xe1' \
+            b'\x10\x00\x00\x00' b'\x00\x00\x00\x03' \
+            b'\x00\x01\x00\x02' b'\x00\x03\x00\x00'
 
         self.req_args_5 = {
             'mode': 0,
@@ -794,10 +802,10 @@
             'window': 2016421454,
             'type': 434059096,
             }
-        self.req_bin_5 = '\x12\x00\x00\x08' '\x78\x30\x26\x4e' \
-            '\x53\x8c\x0f\x22' '\x19\xdf\x37\x58' \
-            '\x10\x00\x00\x00' '\x00\x00\x00\x04' \
-            '\x00\x01\x00\x02' '\x00\x03\x00\x04'
+        self.req_bin_5 = b'\x12\x00\x00\x08' b'\x78\x30\x26\x4e' \
+            b'\x53\x8c\x0f\x22' b'\x19\xdf\x37\x58' \
+            b'\x10\x00\x00\x00' b'\x00\x00\x00\x04' \
+            b'\x00\x01\x00\x02' b'\x00\x03\x00\x04'
 
         self.req_args_6 = {
             'mode': 2,
@@ -806,9 +814,9 @@
             'window': 461926013,
             'type': 613217208,
             }
-        self.req_bin_6 = '\x12\x02\x00\x06' '\x1b\x88\x6e\x7d' \
-            '\x3c\x23\x1c\xbb' '\x24\x8c\xf3\xb8' \
-            '\x20\x00\x00\x00' '\x00\x00\x00\x00'
+        self.req_bin_6 = b'\x12\x02\x00\x06' b'\x1b\x88\x6e\x7d' \
+            b'\x3c\x23\x1c\xbb' b'\x24\x8c\xf3\xb8' \
+            b'\x20\x00\x00\x00' b'\x00\x00\x00\x00'
 
         self.req_args_7 = {
             'mode': 1,
@@ -817,15 +825,15 @@
             'window': 367636986,
             'type': 1085552939,
             }
-        self.req_bin_7 = '\x12\x01\x00\x09' '\x15\xe9\xb1\xfa' \
-            '\x57\xc4\x9f\x58' '\x40\xb4\x39\x2b' \
-            '\x20\x00\x00\x00' '\x00\x00\x00\x03' \
-            '\x00\x00\x00\x01' '\x00\x00\x00\x02' \
-            '\x00\x00\x00\x03'
+        self.req_bin_7 = b'\x12\x01\x00\x09' b'\x15\xe9\xb1\xfa' \
+            b'\x57\xc4\x9f\x58' b'\x40\xb4\x39\x2b' \
+            b'\x20\x00\x00\x00' b'\x00\x00\x00\x03' \
+            b'\x00\x00\x00\x01' b'\x00\x00\x00\x02' \
+            b'\x00\x00\x00\x03'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_0)
+        bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -843,7 +851,7 @@
             raise AssertionError(args)
 
     def testPackRequest1(self):
-        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_1)
+        bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_1)
         try:
             assert bin == self.req_bin_1
         except AssertionError:
@@ -861,7 +869,7 @@
             raise AssertionError(args)
 
     def testPackRequest2(self):
-        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_2)
+        bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_2)
         try:
             assert bin == self.req_bin_2
         except AssertionError:
@@ -879,7 +887,7 @@
             raise AssertionError(args)
 
     def testPackRequest3(self):
-        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_3)
+        bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_3)
         try:
             assert bin == self.req_bin_3
         except AssertionError:
@@ -897,7 +905,7 @@
             raise AssertionError(args)
 
     def testPackRequest4(self):
-        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_4)
+        bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_4)
         try:
             assert bin == self.req_bin_4
         except AssertionError:
@@ -915,7 +923,7 @@
             raise AssertionError(args)
 
     def testPackRequest5(self):
-        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_5)
+        bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_5)
         try:
             assert bin == self.req_bin_5
         except AssertionError:
@@ -933,7 +941,7 @@
             raise AssertionError(args)
 
     def testPackRequest6(self):
-        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_6)
+        bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_6)
         try:
             assert bin == self.req_bin_6
         except AssertionError:
@@ -951,7 +959,7 @@
             raise AssertionError(args)
 
     def testPackRequest7(self):
-        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_7)
+        bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_7)
         try:
             assert bin == self.req_bin_7
         except AssertionError:
@@ -975,12 +983,12 @@
             'property': 506897017,
             'window': 381870530,
             }
-        self.req_bin_0 = '\x13\x00\x00\x03' '\x16\xc2\xe1\xc2' \
-            '\x1e\x36\xa2\x79'
+        self.req_bin_0 = b'\x13\x00\x00\x03' b'\x16\xc2\xe1\xc2' \
+            b'\x1e\x36\xa2\x79'
 
 
     def testPackRequest0(self):
-        bin = apply(request.DeleteProperty._request.to_binary, (), self.req_args_0)
+        bin = request.DeleteProperty._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1008,9 +1016,9 @@
             'window': 1477792536,
             'long_length': 1346507413,
             }
-        self.req_bin_0 = '\x14\x00\x00\x06' '\x58\x15\x53\x18' \
-            '\x3c\x11\x6b\x13' '\x5c\xc5\x9b\xa0' \
-            '\x5d\x30\x8c\xce' '\x50\x42\x12\x95'
+        self.req_bin_0 = b'\x14\x00\x00\x06' b'\x58\x15\x53\x18' \
+            b'\x3c\x11\x6b\x13' b'\x5c\xc5\x9b\xa0' \
+            b'\x5d\x30\x8c\xce' b'\x50\x42\x12\x95'
 
         self.reply_args_0 = {
             'value': (8, ''),
@@ -1018,10 +1026,10 @@
             'property_type': 1392423916,
             'bytes_after': 2046056935,
             }
-        self.reply_bin_0 = '\x01\x08\x77\x8e' '\x00\x00\x00\x00' \
-            '\x52\xfe\xb3\xec' '\x79\xf4\x59\xe7' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x08\x77\x8e' b'\x00\x00\x00\x00' \
+            b'\x52\xfe\xb3\xec' b'\x79\xf4\x59\xe7' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
         self.reply_args_1 = {
             'value': (8, 'foo'),
@@ -1029,11 +1037,11 @@
             'property_type': 186441230,
             'bytes_after': 469299413,
             }
-        self.reply_bin_1 = '\x01\x08\xac\xf7' '\x00\x00\x00\x01' \
-            '\x0b\x1c\xde\x0e' '\x1b\xf8\xf0\xd5' \
-            '\x00\x00\x00\x03' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x66\x6f\x6f\x00'
+        self.reply_bin_1 = b'\x01\x08\xac\xf7' b'\x00\x00\x00\x01' \
+            b'\x0b\x1c\xde\x0e' b'\x1b\xf8\xf0\xd5' \
+            b'\x00\x00\x00\x03' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x66\x6f\x6f\x00'
 
         self.reply_args_2 = {
             'value': (8, 'zoom'),
@@ -1041,11 +1049,11 @@
             'property_type': 1802804296,
             'bytes_after': 1968158856,
             }
-        self.reply_bin_2 = '\x01\x08\x31\x82' '\x00\x00\x00\x01' \
-            '\x6b\x74\x9c\x48' '\x75\x4f\xb8\x88' \
-            '\x00\x00\x00\x04' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x7a\x6f\x6f\x6d'
+        self.reply_bin_2 = b'\x01\x08\x31\x82' b'\x00\x00\x00\x01' \
+            b'\x6b\x74\x9c\x48' b'\x75\x4f\xb8\x88' \
+            b'\x00\x00\x00\x04' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x7a\x6f\x6f\x6d'
 
         self.reply_args_3 = {
             'value': (16, []),
@@ -1053,10 +1061,10 @@
             'property_type': 536196393,
             'bytes_after': 1874157309,
             }
-        self.reply_bin_3 = '\x01\x10\x62\xdf' '\x00\x00\x00\x00' \
-            '\x1f\xf5\xb5\x29' '\x6f\xb5\x5e\xfd' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_3 = b'\x01\x10\x62\xdf' b'\x00\x00\x00\x00' \
+            b'\x1f\xf5\xb5\x29' b'\x6f\xb5\x5e\xfd' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
         self.reply_args_4 = {
             'value': (16, [1, 2, 3]),
@@ -1064,11 +1072,11 @@
             'property_type': 1046879880,
             'bytes_after': 1952710167,
             }
-        self.reply_bin_4 = '\x01\x10\x58\x89' '\x00\x00\x00\x02' \
-            '\x3e\x66\x1e\x88' '\x74\x63\xfe\x17' \
-            '\x00\x00\x00\x03' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x01\x00\x02' '\x00\x03\x00\x00'
+        self.reply_bin_4 = b'\x01\x10\x58\x89' b'\x00\x00\x00\x02' \
+            b'\x3e\x66\x1e\x88' b'\x74\x63\xfe\x17' \
+            b'\x00\x00\x00\x03' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x01\x00\x02' b'\x00\x03\x00\x00'
 
         self.reply_args_5 = {
             'value': (16, [1, 2, 3, 4]),
@@ -1076,11 +1084,11 @@
             'property_type': 1014173132,
             'bytes_after': 1791090668,
             }
-        self.reply_bin_5 = '\x01\x10\x4a\x54' '\x00\x00\x00\x02' \
-            '\x3c\x73\x0d\xcc' '\x6a\xc1\xdf\xec' \
-            '\x00\x00\x00\x04' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x01\x00\x02' '\x00\x03\x00\x04'
+        self.reply_bin_5 = b'\x01\x10\x4a\x54' b'\x00\x00\x00\x02' \
+            b'\x3c\x73\x0d\xcc' b'\x6a\xc1\xdf\xec' \
+            b'\x00\x00\x00\x04' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x01\x00\x02' b'\x00\x03\x00\x04'
 
         self.reply_args_6 = {
             'value': (32, []),
@@ -1088,10 +1096,10 @@
             'property_type': 2053870497,
             'bytes_after': 1727548898,
             }
-        self.reply_bin_6 = '\x01\x20\xb8\x7a' '\x00\x00\x00\x00' \
-            '\x7a\x6b\x93\xa1' '\x66\xf8\x4d\xe2' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_6 = b'\x01\x20\xb8\x7a' b'\x00\x00\x00\x00' \
+            b'\x7a\x6b\x93\xa1' b'\x66\xf8\x4d\xe2' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
         self.reply_args_7 = {
             'value': (32, [1, 2, 3]),
@@ -1099,16 +1107,16 @@
             'property_type': 704363625,
             'bytes_after': 1957409055,
             }
-        self.reply_bin_7 = '\x01\x20\x90\xe6' '\x00\x00\x00\x03' \
-            '\x29\xfb\xbc\x69' '\x74\xab\xb1\x1f' \
-            '\x00\x00\x00\x03' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x01' '\x00\x00\x00\x02' \
-            '\x00\x00\x00\x03'
+        self.reply_bin_7 = b'\x01\x20\x90\xe6' b'\x00\x00\x00\x03' \
+            b'\x29\xfb\xbc\x69' b'\x74\xab\xb1\x1f' \
+            b'\x00\x00\x00\x03' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x01' b'\x00\x00\x00\x02' \
+            b'\x00\x00\x00\x03'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetProperty._request.to_binary, (), self.req_args_0)
+        bin = request.GetProperty._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1126,7 +1134,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -1144,7 +1152,7 @@
             raise AssertionError(args)
 
     def testPackReply1(self):
-        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_1)
+        bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_1)
         try:
             assert bin == self.reply_bin_1
         except AssertionError:
@@ -1162,7 +1170,7 @@
             raise AssertionError(args)
 
     def testPackReply2(self):
-        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_2)
+        bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_2)
         try:
             assert bin == self.reply_bin_2
         except AssertionError:
@@ -1180,7 +1188,7 @@
             raise AssertionError(args)
 
     def testPackReply3(self):
-        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_3)
+        bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_3)
         try:
             assert bin == self.reply_bin_3
         except AssertionError:
@@ -1198,7 +1206,7 @@
             raise AssertionError(args)
 
     def testPackReply4(self):
-        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_4)
+        bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_4)
         try:
             assert bin == self.reply_bin_4
         except AssertionError:
@@ -1216,7 +1224,7 @@
             raise AssertionError(args)
 
     def testPackReply5(self):
-        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_5)
+        bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_5)
         try:
             assert bin == self.reply_bin_5
         except AssertionError:
@@ -1234,7 +1242,7 @@
             raise AssertionError(args)
 
     def testPackReply6(self):
-        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_6)
+        bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_6)
         try:
             assert bin == self.reply_bin_6
         except AssertionError:
@@ -1252,7 +1260,7 @@
             raise AssertionError(args)
 
     def testPackReply7(self):
-        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_7)
+        bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_7)
         try:
             assert bin == self.reply_bin_7
         except AssertionError:
@@ -1275,32 +1283,32 @@
         self.req_args_0 = {
             'window': 91262675,
             }
-        self.req_bin_0 = '\x15\x00\x00\x02' '\x05\x70\x8e\xd3'
+        self.req_bin_0 = b'\x15\x00\x00\x02' b'\x05\x70\x8e\xd3'
 
         self.reply_args_0 = {
             'atoms': [580972634, 926488735, 714741529, 408777797, 679906858, 705092899, 2063243279, 893967755, 1591182471, 571137996, 1677110101, 1783836762, 1678219148, 1992402577, 871298793, 1182885899, 1155013854, 1822076326, 2117552706, 1972668469, 1660227078, 1523268962, 694042433],
             'sequence_number': 42191,
             }
-        self.reply_bin_0 = '\x01\x00\xa4\xcf' '\x00\x00\x00\x17' \
-            '\x00\x17\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x22\xa0\xf0\x5a' '\x37\x39\x18\x9f' \
-            '\x2a\x9a\x17\x19' '\x18\x5d\x74\x45' \
-            '\x28\x86\x8e\x2a' '\x2a\x06\xdd\x23' \
-            '\x7a\xfa\x98\x0f' '\x35\x48\xdd\x8b' \
-            '\x5e\xd7\x84\x87' '\x22\x0a\xdf\xcc' \
-            '\x63\xf6\xab\x55' '\x6a\x53\x30\x5a' \
-            '\x64\x07\x97\x8c' '\x76\xc1\xa6\x91' \
-            '\x33\xee\xf6\xe9' '\x46\x81\x68\x0b' \
-            '\x44\xd8\x1c\xde' '\x6c\x9a\xad\xa6' \
-            '\x7e\x37\x4a\x42' '\x75\x94\x88\x35' \
-            '\x62\xf5\x0e\x06' '\x5a\xcb\x3d\x62' \
-            '\x29\x5e\x3f\x41'
+        self.reply_bin_0 = b'\x01\x00\xa4\xcf' b'\x00\x00\x00\x17' \
+            b'\x00\x17\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x22\xa0\xf0\x5a' b'\x37\x39\x18\x9f' \
+            b'\x2a\x9a\x17\x19' b'\x18\x5d\x74\x45' \
+            b'\x28\x86\x8e\x2a' b'\x2a\x06\xdd\x23' \
+            b'\x7a\xfa\x98\x0f' b'\x35\x48\xdd\x8b' \
+            b'\x5e\xd7\x84\x87' b'\x22\x0a\xdf\xcc' \
+            b'\x63\xf6\xab\x55' b'\x6a\x53\x30\x5a' \
+            b'\x64\x07\x97\x8c' b'\x76\xc1\xa6\x91' \
+            b'\x33\xee\xf6\xe9' b'\x46\x81\x68\x0b' \
+            b'\x44\xd8\x1c\xde' b'\x6c\x9a\xad\xa6' \
+            b'\x7e\x37\x4a\x42' b'\x75\x94\x88\x35' \
+            b'\x62\xf5\x0e\x06' b'\x5a\xcb\x3d\x62' \
+            b'\x29\x5e\x3f\x41'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ListProperties._request.to_binary, (), self.req_args_0)
+        bin = request.ListProperties._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1318,7 +1326,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.ListProperties._reply.to_binary, (), self.reply_args_0)
+        bin = request.ListProperties._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -1343,12 +1351,12 @@
             'window': 1190911777,
             'time': 1606660593,
             }
-        self.req_bin_0 = '\x16\x00\x00\x04' '\x46\xfb\xdf\x21' \
-            '\x7b\x74\xe4\x1b' '\x5f\xc3\xb1\xf1'
+        self.req_bin_0 = b'\x16\x00\x00\x04' b'\x46\xfb\xdf\x21' \
+            b'\x7b\x74\xe4\x1b' b'\x5f\xc3\xb1\xf1'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetSelectionOwner._request.to_binary, (), self.req_args_0)
+        bin = request.SetSelectionOwner._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1371,20 +1379,20 @@
         self.req_args_0 = {
             'selection': 819576555,
             }
-        self.req_bin_0 = '\x17\x00\x00\x02' '\x30\xd9\xbe\xeb'
+        self.req_bin_0 = b'\x17\x00\x00\x02' b'\x30\xd9\xbe\xeb'
 
         self.reply_args_0 = {
             'sequence_number': 14152,
             'owner': 1922331178,
             }
-        self.reply_bin_0 = '\x01\x00\x37\x48' '\x00\x00\x00\x00' \
-            '\x72\x94\x72\x2a' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\x37\x48' b'\x00\x00\x00\x00' \
+            b'\x72\x94\x72\x2a' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetSelectionOwner._request.to_binary, (), self.req_args_0)
+        bin = request.GetSelectionOwner._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1402,7 +1410,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetSelectionOwner._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetSelectionOwner._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -1429,13 +1437,13 @@
             'selection': 125139929,
             'requestor': 300355135,
             }
-        self.req_bin_0 = '\x18\x00\x00\x06' '\x11\xe7\x0e\x3f' \
-            '\x07\x75\x7b\xd9' '\x75\x8e\x82\x08' \
-            '\x7f\x6c\x1d\xb7' '\x5f\x0c\x79\xd6'
+        self.req_bin_0 = b'\x18\x00\x00\x06' b'\x11\xe7\x0e\x3f' \
+            b'\x07\x75\x7b\xd9' b'\x75\x8e\x82\x08' \
+            b'\x7f\x6c\x1d\xb7' b'\x5f\x0c\x79\xd6'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ConvertSelection._request.to_binary, (), self.req_args_0)
+        bin = request.ConvertSelection._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1461,16 +1469,16 @@
             'destination': 1369243800,
             'event_mask': 1594482936,
             }
-        self.req_bin_0 = '\x19\x01\x00\x0b' '\x51\x9d\x00\x98' \
-            '\x5f\x09\xe0\xf8' '\x0c\x00\x00\x00' \
-            '\x4e\xce\xfa\x94' '\xcd\x42\xdb\xfc' \
-            '\x40\xe4\xfd\x10' '\x37\x54\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00'
+        self.req_bin_0 = b'\x19\x01\x00\x0b' b'\x51\x9d\x00\x98' \
+            b'\x5f\x09\xe0\xf8' b'\x0c\x00\x00\x00' \
+            b'\x4e\xce\xfa\x94' b'\xcd\x42\xdb\xfc' \
+            b'\x40\xe4\xfd\x10' b'\x37\x54\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SendEvent._request.to_binary, (), self.req_args_0)
+        bin = request.SendEvent._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1500,22 +1508,22 @@
             'keyboard_mode': 1,
             'cursor': 17101598,
             }
-        self.req_bin_0 = '\x1a\x01\x00\x06' '\x7d\x75\x91\xbc' \
-            '\x08\x1b\x00\x01' '\x76\x82\xb9\x57' \
-            '\x01\x04\xf3\x1e' '\x4e\x77\x17\xcc'
+        self.req_bin_0 = b'\x1a\x01\x00\x06' b'\x7d\x75\x91\xbc' \
+            b'\x08\x1b\x00\x01' b'\x76\x82\xb9\x57' \
+            b'\x01\x04\xf3\x1e' b'\x4e\x77\x17\xcc'
 
         self.reply_args_0 = {
             'sequence_number': 47539,
             'status': 149,
             }
-        self.reply_bin_0 = '\x01\x95\xb9\xb3' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x95\xb9\xb3' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GrabPointer._request.to_binary, (), self.req_args_0)
+        bin = request.GrabPointer._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1533,7 +1541,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GrabPointer._reply.to_binary, (), self.reply_args_0)
+        bin = request.GrabPointer._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -1556,11 +1564,11 @@
         self.req_args_0 = {
             'time': 209008422,
             }
-        self.req_bin_0 = '\x1b\x00\x00\x02' '\x0c\x75\x37\x26'
+        self.req_bin_0 = b'\x1b\x00\x00\x02' b'\x0c\x75\x37\x26'
 
 
     def testPackRequest0(self):
-        bin = apply(request.UngrabPointer._request.to_binary, (), self.req_args_0)
+        bin = request.UngrabPointer._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1591,13 +1599,13 @@
             'keyboard_mode': 1,
             'cursor': 1070323643,
             }
-        self.req_bin_0 = '\x1c\x01\x00\x06' '\x1f\x60\x42\x88' \
-            '\x3f\x97\x01\x01' '\x6d\xe8\x6c\x5b' \
-            '\x3f\xcb\xd7\xbb' '\xd0\x00\x3c\xe5'
+        self.req_bin_0 = b'\x1c\x01\x00\x06' b'\x1f\x60\x42\x88' \
+            b'\x3f\x97\x01\x01' b'\x6d\xe8\x6c\x5b' \
+            b'\x3f\xcb\xd7\xbb' b'\xd0\x00\x3c\xe5'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GrabButton._request.to_binary, (), self.req_args_0)
+        bin = request.GrabButton._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1622,12 +1630,12 @@
             'button': 240,
             'modifiers': 51717,
             }
-        self.req_bin_0 = '\x1d\xf0\x00\x03' '\x2f\x69\x0e\x86' \
-            '\xca\x05\x00\x00'
+        self.req_bin_0 = b'\x1d\xf0\x00\x03' b'\x2f\x69\x0e\x86' \
+            b'\xca\x05\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.UngrabButton._request.to_binary, (), self.req_args_0)
+        bin = request.UngrabButton._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1652,12 +1660,12 @@
             'event_mask': 23423,
             'cursor': 1696594928,
             }
-        self.req_bin_0 = '\x1e\x00\x00\x04' '\x65\x1f\xfb\xf0' \
-            '\x35\x20\xbb\x64' '\x5b\x7f\x00\x00'
+        self.req_bin_0 = b'\x1e\x00\x00\x04' b'\x65\x1f\xfb\xf0' \
+            b'\x35\x20\xbb\x64' b'\x5b\x7f\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangeActivePointerGrab._request.to_binary, (), self.req_args_0)
+        bin = request.ChangeActivePointerGrab._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1684,21 +1692,21 @@
             'pointer_mode': 1,
             'keyboard_mode': 1,
             }
-        self.req_bin_0 = '\x1f\x00\x00\x04' '\x04\x89\xaf\x67' \
-            '\x5d\x23\x78\xd9' '\x01\x01\x00\x00'
+        self.req_bin_0 = b'\x1f\x00\x00\x04' b'\x04\x89\xaf\x67' \
+            b'\x5d\x23\x78\xd9' b'\x01\x01\x00\x00'
 
         self.reply_args_0 = {
             'sequence_number': 9648,
             'status': 129,
             }
-        self.reply_bin_0 = '\x01\x81\x25\xb0' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x81\x25\xb0' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GrabKeyboard._request.to_binary, (), self.req_args_0)
+        bin = request.GrabKeyboard._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1716,7 +1724,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GrabKeyboard._reply.to_binary, (), self.reply_args_0)
+        bin = request.GrabKeyboard._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -1739,11 +1747,11 @@
         self.req_args_0 = {
             'time': 1352311886,
             }
-        self.req_bin_0 = '\x20\x00\x00\x02' '\x50\x9a\xa4\x4e'
+        self.req_bin_0 = b'\x20\x00\x00\x02' b'\x50\x9a\xa4\x4e'
 
 
     def testPackRequest0(self):
-        bin = apply(request.UngrabKeyboard._request.to_binary, (), self.req_args_0)
+        bin = request.UngrabKeyboard._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1771,12 +1779,12 @@
             'modifiers': 28819,
             'key': 193,
             }
-        self.req_bin_0 = '\x21\x01\x00\x04' '\x57\x78\x21\xf0' \
-            '\x70\x93\xc1\x00' '\x00\x00\x00\x00'
+        self.req_bin_0 = b'\x21\x01\x00\x04' b'\x57\x78\x21\xf0' \
+            b'\x70\x93\xc1\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GrabKey._request.to_binary, (), self.req_args_0)
+        bin = request.GrabKey._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1801,12 +1809,12 @@
             'key': 215,
             'modifiers': 60588,
             }
-        self.req_bin_0 = '\x22\xd7\x00\x03' '\x2d\xe4\x31\xbb' \
-            '\xec\xac\x00\x00'
+        self.req_bin_0 = b'\x22\xd7\x00\x03' b'\x2d\xe4\x31\xbb' \
+            b'\xec\xac\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.UngrabKey._request.to_binary, (), self.req_args_0)
+        bin = request.UngrabKey._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1830,11 +1838,11 @@
             'time': 342147129,
             'mode': 1,
             }
-        self.req_bin_0 = '\x23\x01\x00\x02' '\x14\x64\xc0\x39'
+        self.req_bin_0 = b'\x23\x01\x00\x02' b'\x14\x64\xc0\x39'
 
 
     def testPackRequest0(self):
-        bin = apply(request.AllowEvents._request.to_binary, (), self.req_args_0)
+        bin = request.AllowEvents._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1856,11 +1864,11 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x24\x00\x00\x01'
+        self.req_bin_0 = b'\x24\x00\x00\x01'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GrabServer._request.to_binary, (), self.req_args_0)
+        bin = request.GrabServer._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1882,11 +1890,11 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x25\x00\x00\x01'
+        self.req_bin_0 = b'\x25\x00\x00\x01'
 
 
     def testPackRequest0(self):
-        bin = apply(request.UngrabServer._request.to_binary, (), self.req_args_0)
+        bin = request.UngrabServer._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1909,7 +1917,7 @@
         self.req_args_0 = {
             'window': 561336799,
             }
-        self.req_bin_0 = '\x26\x00\x00\x02' '\x21\x75\x51\xdf'
+        self.req_bin_0 = b'\x26\x00\x00\x02' b'\x21\x75\x51\xdf'
 
         self.reply_args_0 = {
             'win_y': -25733,
@@ -1922,14 +1930,14 @@
             'child': 1075058918,
             'win_x': -18858,
             }
-        self.reply_bin_0 = '\x01\x00\xa1\xe8' '\x00\x00\x00\x00' \
-            '\x5f\x52\x73\x56' '\x40\x14\x18\xe6' \
-            '\xef\xa7\xe8\x20' '\xb6\x56\x9b\x7b' \
-            '\x8c\x73\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\xa1\xe8' b'\x00\x00\x00\x00' \
+            b'\x5f\x52\x73\x56' b'\x40\x14\x18\xe6' \
+            b'\xef\xa7\xe8\x20' b'\xb6\x56\x9b\x7b' \
+            b'\x8c\x73\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.QueryPointer._request.to_binary, (), self.req_args_0)
+        bin = request.QueryPointer._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1947,7 +1955,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.QueryPointer._reply.to_binary, (), self.reply_args_0)
+        bin = request.QueryPointer._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -1972,26 +1980,26 @@
             'start': 1520150500,
             'stop': 11115313,
             }
-        self.req_bin_0 = '\x27\x00\x00\x04' '\x32\x49\x8f\xf4' \
-            '\x5a\x9b\xa7\xe4' '\x00\xa9\x9b\x31'
+        self.req_bin_0 = b'\x27\x00\x00\x04' b'\x32\x49\x8f\xf4' \
+            b'\x5a\x9b\xa7\xe4' b'\x00\xa9\x9b\x31'
 
         self.reply_args_0 = {
             'sequence_number': 52222,
             'events': [{'time': 2107444516, 'x': -649, 'y': -11631}, {'time': 1827536960, 'x': -18061, 'y': -2301}, {'time': 554175146, 'x': -32111, 'y': -13522}, {'time': 608168588, 'x': -5963, 'y': -24618}, {'time': 590416221, 'x': -3325, 'y': -19656}],
             }
-        self.reply_bin_0 = '\x01\x00\xcb\xfe' '\x00\x00\x00\x0a' \
-            '\x00\x00\x00\x05' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x7d\x9d\x0d\x24' '\xfd\x77\xd2\x91' \
-            '\x6c\xee\x00\x40' '\xb9\x73\xf7\x03' \
-            '\x21\x08\x0a\xaa' '\x82\x91\xcb\x2e' \
-            '\x24\x3f\xea\x8c' '\xe8\xb5\x9f\xd6' \
-            '\x23\x31\x09\x5d' '\xf3\x03\xb3\x38'
+        self.reply_bin_0 = b'\x01\x00\xcb\xfe' b'\x00\x00\x00\x0a' \
+            b'\x00\x00\x00\x05' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x7d\x9d\x0d\x24' b'\xfd\x77\xd2\x91' \
+            b'\x6c\xee\x00\x40' b'\xb9\x73\xf7\x03' \
+            b'\x21\x08\x0a\xaa' b'\x82\x91\xcb\x2e' \
+            b'\x24\x3f\xea\x8c' b'\xe8\xb5\x9f\xd6' \
+            b'\x23\x31\x09\x5d' b'\xf3\x03\xb3\x38'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetMotionEvents._request.to_binary, (), self.req_args_0)
+        bin = request.GetMotionEvents._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2009,7 +2017,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetMotionEvents._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetMotionEvents._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2035,8 +2043,8 @@
             'src_wid': 257619448,
             'dst_wid': 1238981863,
             }
-        self.req_bin_0 = '\x28\x00\x00\x04' '\x0f\x5a\xf5\xf8' \
-            '\x49\xd9\x5c\xe7' '\x9d\x0d\x95\x91'
+        self.req_bin_0 = b'\x28\x00\x00\x04' b'\x0f\x5a\xf5\xf8' \
+            b'\x49\xd9\x5c\xe7' b'\x9d\x0d\x95\x91'
 
         self.reply_args_0 = {
             'child': 2050350678,
@@ -2045,14 +2053,14 @@
             'x': -18096,
             'y': -5252,
             }
-        self.reply_bin_0 = '\x01\x01\x97\x01' '\x00\x00\x00\x00' \
-            '\x7a\x35\xde\x56' '\xb9\x50\xeb\x7c' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x01\x97\x01' b'\x00\x00\x00\x00' \
+            b'\x7a\x35\xde\x56' b'\xb9\x50\xeb\x7c' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.TranslateCoords._request.to_binary, (), self.req_args_0)
+        bin = request.TranslateCoords._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2070,7 +2078,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.TranslateCoords._reply.to_binary, (), self.reply_args_0)
+        bin = request.TranslateCoords._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2100,13 +2108,13 @@
             'dst_x': -30516,
             'dst_y': -24204,
             }
-        self.req_bin_0 = '\x29\x00\x00\x06' '\x4f\x93\xba\xef' \
-            '\x28\x44\x07\xf4' '\x96\x11\x9a\x29' \
-            '\x55\x31\xdd\x3a' '\x88\xcc\xa1\x74'
+        self.req_bin_0 = b'\x29\x00\x00\x06' b'\x4f\x93\xba\xef' \
+            b'\x28\x44\x07\xf4' b'\x96\x11\x9a\x29' \
+            b'\x55\x31\xdd\x3a' b'\x88\xcc\xa1\x74'
 
 
     def testPackRequest0(self):
-        bin = apply(request.WarpPointer._request.to_binary, (), self.req_args_0)
+        bin = request.WarpPointer._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2131,12 +2139,12 @@
             'time': 1079702500,
             'focus': 1026400247,
             }
-        self.req_bin_0 = '\x2a\x01\x00\x03' '\x3d\x2d\x9f\xf7' \
-            '\x40\x5a\xf3\xe4'
+        self.req_bin_0 = b'\x2a\x01\x00\x03' b'\x3d\x2d\x9f\xf7' \
+            b'\x40\x5a\xf3\xe4'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetInputFocus._request.to_binary, (), self.req_args_0)
+        bin = request.SetInputFocus._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2158,21 +2166,21 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x2b\x00\x00\x01'
+        self.req_bin_0 = b'\x2b\x00\x00\x01'
 
         self.reply_args_0 = {
             'revert_to': 152,
             'sequence_number': 16002,
             'focus': 2024022965,
             }
-        self.reply_bin_0 = '\x01\x98\x3e\x82' '\x00\x00\x00\x00' \
-            '\x78\xa4\x23\xb5' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x98\x3e\x82' b'\x00\x00\x00\x00' \
+            b'\x78\xa4\x23\xb5' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetInputFocus._request.to_binary, (), self.req_args_0)
+        bin = request.GetInputFocus._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2190,7 +2198,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetInputFocus._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetInputFocus._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2212,21 +2220,21 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x2c\x00\x00\x01'
+        self.req_bin_0 = b'\x2c\x00\x00\x01'
 
         self.reply_args_0 = {
             'sequence_number': 16233,
             'map': [186, 167, 191, 213, 241, 231, 234, 175, 154, 169, 132, 146, 215, 191, 196, 212, 158, 156, 177, 233, 220, 192, 130, 226, 181, 233, 238, 141, 129, 215, 245, 215],
             }
-        self.reply_bin_0 = '\x01\x00\x3f\x69' '\x00\x00\x00\x02' \
-            '\xba\xa7\xbf\xd5' '\xf1\xe7\xea\xaf' \
-            '\x9a\xa9\x84\x92' '\xd7\xbf\xc4\xd4' \
-            '\x9e\x9c\xb1\xe9' '\xdc\xc0\x82\xe2' \
-            '\xb5\xe9\xee\x8d' '\x81\xd7\xf5\xd7'
+        self.reply_bin_0 = b'\x01\x00\x3f\x69' b'\x00\x00\x00\x02' \
+            b'\xba\xa7\xbf\xd5' b'\xf1\xe7\xea\xaf' \
+            b'\x9a\xa9\x84\x92' b'\xd7\xbf\xc4\xd4' \
+            b'\x9e\x9c\xb1\xe9' b'\xdc\xc0\x82\xe2' \
+            b'\xb5\xe9\xee\x8d' b'\x81\xd7\xf5\xd7'
 
 
     def testPackRequest0(self):
-        bin = apply(request.QueryKeymap._request.to_binary, (), self.req_args_0)
+        bin = request.QueryKeymap._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2244,7 +2252,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.QueryKeymap._reply.to_binary, (), self.reply_args_0)
+        bin = request.QueryKeymap._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2268,13 +2276,13 @@
             'fid': 1728036313,
             'name': 'foofont',
             }
-        self.req_bin_0 = '\x2d\x00\x00\x05' '\x66\xff\xbd\xd9' \
-            '\x00\x07\x00\x00' '\x66\x6f\x6f\x66' \
-            '\x6f\x6e\x74\x00'
+        self.req_bin_0 = b'\x2d\x00\x00\x05' b'\x66\xff\xbd\xd9' \
+            b'\x00\x07\x00\x00' b'\x66\x6f\x6f\x66' \
+            b'\x6f\x6e\x74\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.OpenFont._request.to_binary, (), self.req_args_0)
+        bin = request.OpenFont._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2297,11 +2305,11 @@
         self.req_args_0 = {
             'font': 1139770507,
             }
-        self.req_bin_0 = '\x2e\x00\x00\x02' '\x43\xef\x84\x8b'
+        self.req_bin_0 = b'\x2e\x00\x00\x02' b'\x43\xef\x84\x8b'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CloseFont._request.to_binary, (), self.req_args_0)
+        bin = request.CloseFont._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2324,7 +2332,7 @@
         self.req_args_0 = {
             'font': 1867659050,
             }
-        self.req_bin_0 = '\x2f\x00\x00\x02' '\x6f\x52\x37\x2a'
+        self.req_bin_0 = b'\x2f\x00\x00\x02' b'\x6f\x52\x37\x2a'
 
         self.reply_args_0 = {
             'sequence_number': 8877,
@@ -2342,23 +2350,23 @@
             'font_descent': -23067,
             'max_bounds': {'descent': -24292, 'ascent': -26972, 'character_width': -19286, 'left_side_bearing': -16363, 'right_side_bearing': -3149, 'attributes': 35968},
             }
-        self.reply_bin_0 = '\x01\x00\x22\xad' '\x00\x00\x00\x12' \
-            '\xae\xfc\xab\x3e' '\xeb\x5a\x96\x67' \
-            '\x8b\x8b\x2c\x80' '\x00\x00\x00\x00' \
-            '\xc0\x15\xf3\xb3' '\xb4\xaa\x96\xa4' \
-            '\xa1\x1c\x8c\x80' '\x00\x00\x00\x00' \
-            '\xc0\xd0\x09\xd4' '\x23\x22\x00\x01' \
-            '\x8f\xbe\xa8\x01' '\xc2\xe2\xa5\xe5' \
-            '\x00\x00\x00\x03' '\x56\x76\x30\xf3' \
-            '\x7d\xc9\x5e\x19' '\xee\x57\xd9\x6d' \
-            '\x90\x97\xc7\x8a' '\xfe\xb5\xd7\x97' \
-            '\xb0\x53\x9d\x9d' '\xee\x4c\xe7\x7a' \
-            '\xb6\xcd\x73\x24' '\xb1\x9c\xfc\x76' \
-            '\xaa\xa1\xf6\xb6' '\xb8\x33\x86\x51'
+        self.reply_bin_0 = b'\x01\x00\x22\xad' b'\x00\x00\x00\x12' \
+            b'\xae\xfc\xab\x3e' b'\xeb\x5a\x96\x67' \
+            b'\x8b\x8b\x2c\x80' b'\x00\x00\x00\x00' \
+            b'\xc0\x15\xf3\xb3' b'\xb4\xaa\x96\xa4' \
+            b'\xa1\x1c\x8c\x80' b'\x00\x00\x00\x00' \
+            b'\xc0\xd0\x09\xd4' b'\x23\x22\x00\x01' \
+            b'\x8f\xbe\xa8\x01' b'\xc2\xe2\xa5\xe5' \
+            b'\x00\x00\x00\x03' b'\x56\x76\x30\xf3' \
+            b'\x7d\xc9\x5e\x19' b'\xee\x57\xd9\x6d' \
+            b'\x90\x97\xc7\x8a' b'\xfe\xb5\xd7\x97' \
+            b'\xb0\x53\x9d\x9d' b'\xee\x4c\xe7\x7a' \
+            b'\xb6\xcd\x73\x24' b'\xb1\x9c\xfc\x76' \
+            b'\xaa\xa1\xf6\xb6' b'\xb8\x33\x86\x51'
 
 
     def testPackRequest0(self):
-        bin = apply(request.QueryFont._request.to_binary, (), self.req_args_0)
+        bin = request.QueryFont._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2376,7 +2384,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.QueryFont._reply.to_binary, (), self.reply_args_0)
+        bin = request.QueryFont._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2400,8 +2408,8 @@
             'font': 1562125736,
             'string': (102, 111, 111),
             }
-        self.req_bin_0 = '\x30\x01\x00\x04' '\x5d\x1c\x25\xa8' \
-            '\x00\x66\x00\x6f' '\x00\x6f\x00\x00'
+        self.req_bin_0 = b'\x30\x01\x00\x04' b'\x5d\x1c\x25\xa8' \
+            b'\x00\x66\x00\x6f' b'\x00\x6f\x00\x00'
 
         self.reply_args_0 = {
             'overall_width': -1378352414,
@@ -2414,14 +2422,14 @@
             'overall_left': -1046976699,
             'font_descent': -14179,
             }
-        self.reply_bin_0 = '\x01\xdb\x1a\x87' '\x00\x00\x00\x00' \
-            '\xbd\xed\xc8\x9d' '\xa6\x82\xf8\xfd' \
-            '\xad\xd8\x02\xe2' '\xc1\x98\x67\x45' \
-            '\xe0\x64\x80\xea' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\xdb\x1a\x87' b'\x00\x00\x00\x00' \
+            b'\xbd\xed\xc8\x9d' b'\xa6\x82\xf8\xfd' \
+            b'\xad\xd8\x02\xe2' b'\xc1\x98\x67\x45' \
+            b'\xe0\x64\x80\xea' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.QueryTextExtents._request.to_binary, (), self.req_args_0)
+        bin = request.QueryTextExtents._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2439,7 +2447,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.QueryTextExtents._reply.to_binary, (), self.reply_args_0)
+        bin = request.QueryTextExtents._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2463,24 +2471,24 @@
             'max_names': 53961,
             'pattern': 'bhazr',
             }
-        self.req_bin_0 = '\x31\x00\x00\x04' '\xd2\xc9\x00\x05' \
-            '\x62\x68\x61\x7a' '\x72\x00\x00\x00'
+        self.req_bin_0 = b'\x31\x00\x00\x04' b'\xd2\xc9\x00\x05' \
+            b'\x62\x68\x61\x7a' b'\x72\x00\x00\x00'
 
         self.reply_args_0 = {
             'fonts': ['fie', 'fuzzy', 'foozooom'],
             'sequence_number': 38267,
             }
-        self.reply_bin_0 = '\x01\x00\x95\x7b' '\x00\x00\x00\x05' \
-            '\x00\x03\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x03\x66\x69\x65' '\x05\x66\x75\x7a' \
-            '\x7a\x79\x08\x66' '\x6f\x6f\x7a\x6f' \
-            '\x6f\x6f\x6d\x00'
+        self.reply_bin_0 = b'\x01\x00\x95\x7b' b'\x00\x00\x00\x05' \
+            b'\x00\x03\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x03\x66\x69\x65' b'\x05\x66\x75\x7a' \
+            b'\x7a\x79\x08\x66' b'\x6f\x6f\x7a\x6f' \
+            b'\x6f\x6f\x6d\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ListFonts._request.to_binary, (), self.req_args_0)
+        bin = request.ListFonts._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2498,7 +2506,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.ListFonts._reply.to_binary, (), self.reply_args_0)
+        bin = request.ListFonts._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2522,8 +2530,8 @@
             'max_names': 46571,
             'pattern': 'bhazr2',
             }
-        self.req_bin_0 = '\x32\x00\x00\x04' '\xb5\xeb\x00\x06' \
-            '\x62\x68\x61\x7a' '\x72\x32\x00\x00'
+        self.req_bin_0 = b'\x32\x00\x00\x04' b'\xb5\xeb\x00\x06' \
+            b'\x62\x68\x61\x7a' b'\x72\x32\x00\x00'
 
         self.reply_args_0 = {
             'sequence_number': 20014,
@@ -2542,20 +2550,20 @@
             'font_descent': -28978,
             'max_bounds': {'descent': -20692, 'ascent': -6999, 'character_width': -15180, 'left_side_bearing': -7789, 'right_side_bearing': -5339, 'attributes': 1068},
             }
-        self.reply_bin_0 = '\x01\x08\x4e\x2e' '\x00\x00\x00\x0b' \
-            '\x8b\xb9\x83\x5c' '\xcd\x1e\xc6\x49' \
-            '\x93\x43\x09\xa1' '\x00\x00\x00\x00' \
-            '\xe1\x93\xeb\x25' '\xc4\xb4\xe4\xa9' \
-            '\xaf\x2c\x04\x2c' '\x00\x00\x00\x00' \
-            '\x68\x0e\x09\xaf' '\x42\x91\x00\x01' \
-            '\xc0\xd6\xd9\x00' '\x88\xaa\x8e\xce' \
-            '\x76\x53\x9a\xa2' '\x19\xfc\x2b\xb0' \
-            '\x7d\xca\x9c\xc9' '\x66\x6f\x6e\x74' \
-            '\x66\x6f\x6e\x74'
+        self.reply_bin_0 = b'\x01\x08\x4e\x2e' b'\x00\x00\x00\x0b' \
+            b'\x8b\xb9\x83\x5c' b'\xcd\x1e\xc6\x49' \
+            b'\x93\x43\x09\xa1' b'\x00\x00\x00\x00' \
+            b'\xe1\x93\xeb\x25' b'\xc4\xb4\xe4\xa9' \
+            b'\xaf\x2c\x04\x2c' b'\x00\x00\x00\x00' \
+            b'\x68\x0e\x09\xaf' b'\x42\x91\x00\x01' \
+            b'\xc0\xd6\xd9\x00' b'\x88\xaa\x8e\xce' \
+            b'\x76\x53\x9a\xa2' b'\x19\xfc\x2b\xb0' \
+            b'\x7d\xca\x9c\xc9' b'\x66\x6f\x6e\x74' \
+            b'\x66\x6f\x6e\x74'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ListFontsWithInfo._request.to_binary, (), self.req_args_0)
+        bin = request.ListFontsWithInfo._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2573,7 +2581,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.ListFontsWithInfo._reply.to_binary, (), self.reply_args_0)
+        bin = request.ListFontsWithInfo._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2596,18 +2604,18 @@
         self.req_args_0 = {
             'path': ['foo', 'bar', 'gazonk'],
             }
-        self.req_bin_0 = '\x33\x00\x00\x06' '\x00\x03\x00\x00' \
-            '\x03\x66\x6f\x6f' '\x03\x62\x61\x72' \
-            '\x06\x67\x61\x7a' '\x6f\x6e\x6b\x00'
+        self.req_bin_0 = b'\x33\x00\x00\x06' b'\x00\x03\x00\x00' \
+            b'\x03\x66\x6f\x6f' b'\x03\x62\x61\x72' \
+            b'\x06\x67\x61\x7a' b'\x6f\x6e\x6b\x00'
 
         self.req_args_1 = {
             'path': [],
             }
-        self.req_bin_1 = '\x33\x00\x00\x02' '\x00\x00\x00\x00'
+        self.req_bin_1 = b'\x33\x00\x00\x02' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetFontPath._request.to_binary, (), self.req_args_0)
+        bin = request.SetFontPath._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2625,7 +2633,7 @@
             raise AssertionError(args)
 
     def testPackRequest1(self):
-        bin = apply(request.SetFontPath._request.to_binary, (), self.req_args_1)
+        bin = request.SetFontPath._request.to_binary(*(), **self.req_args_1)
         try:
             assert bin == self.req_bin_1
         except AssertionError:
@@ -2647,31 +2655,31 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x34\x00\x00\x01'
+        self.req_bin_0 = b'\x34\x00\x00\x01'
 
         self.reply_args_0 = {
             'sequence_number': 21510,
             'paths': ['path1', 'path2232'],
             }
-        self.reply_bin_0 = '\x01\x00\x54\x06' '\x00\x00\x00\x04' \
-            '\x00\x02\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x05\x70\x61\x74' '\x68\x31\x08\x70' \
-            '\x61\x74\x68\x32' '\x32\x33\x32\x00'
+        self.reply_bin_0 = b'\x01\x00\x54\x06' b'\x00\x00\x00\x04' \
+            b'\x00\x02\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x05\x70\x61\x74' b'\x68\x31\x08\x70' \
+            b'\x61\x74\x68\x32' b'\x32\x33\x32\x00'
 
         self.reply_args_1 = {
             'sequence_number': 62463,
             'paths': [],
             }
-        self.reply_bin_1 = '\x01\x00\xf3\xff' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_1 = b'\x01\x00\xf3\xff' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetFontPath._request.to_binary, (), self.req_args_0)
+        bin = request.GetFontPath._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2689,7 +2697,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetFontPath._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetFontPath._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2707,7 +2715,7 @@
             raise AssertionError(args)
 
     def testPackReply1(self):
-        bin = apply(request.GetFontPath._reply.to_binary, (), self.reply_args_1)
+        bin = request.GetFontPath._reply.to_binary(*(), **self.reply_args_1)
         try:
             assert bin == self.reply_bin_1
         except AssertionError:
@@ -2734,12 +2742,12 @@
             'depth': 145,
             'width': 5641,
             }
-        self.req_bin_0 = '\x35\x91\x00\x04' '\x37\x39\x21\x50' \
-            '\x09\xab\xe8\xd2' '\x16\x09\xff\xeb'
+        self.req_bin_0 = b'\x35\x91\x00\x04' b'\x37\x39\x21\x50' \
+            b'\x09\xab\xe8\xd2' b'\x16\x09\xff\xeb'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CreatePixmap._request.to_binary, (), self.req_args_0)
+        bin = request.CreatePixmap._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2762,11 +2770,11 @@
         self.req_args_0 = {
             'pixmap': 213012851,
             }
-        self.req_bin_0 = '\x36\x00\x00\x02' '\x0c\xb2\x51\x73'
+        self.req_bin_0 = b'\x36\x00\x00\x02' b'\x0c\xb2\x51\x73'
 
 
     def testPackRequest0(self):
-        bin = apply(request.FreePixmap._request.to_binary, (), self.req_args_0)
+        bin = request.FreePixmap._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2791,24 +2799,24 @@
             'drawable': 456876463,
             'attrs': {'dashes': 183, 'fill_rule': 0, 'clip_mask': 620422624, 'plane_mask': 1797423280, 'line_style': 1, 'tile': 77620460, 'arc_mode': 0, 'clip_y_origin': -7419, 'dash_offset': 62459, 'line_width': 50494, 'background': 44336037, 'clip_x_origin': -32045, 'join_style': 2, 'graphics_exposures': 0, 'font': 95118395, 'tile_stipple_y_origin': -17619, 'stipple': 631657813, 'fill_style': 0, 'cap_style': 0, 'subwindow_mode': 0, 'tile_stipple_x_origin': -12494, 'foreground': 2096879871, 'function': 10},
             }
-        self.req_bin_0 = '\x37\x00\x00\x1b' '\x3f\x38\x5c\x6a' \
-            '\x1b\x3b\x61\xaf' '\x00\x7f\xff\xff' \
-            '\x0a\x00\x00\x00' '\x6b\x22\x80\xb0' \
-            '\x7c\xfb\xd8\xff' '\x02\xa4\x83\xa5' \
-            '\xc5\x3e\x00\x00' '\x01\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x02\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x04\xa0\x64\xec' '\x25\xa6\x55\x55' \
-            '\xcf\x32\x00\x00' '\xbb\x2d\x00\x00' \
-            '\x05\xab\x64\x3b' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x82\xd3\x00\x00' \
-            '\xe3\x05\x00\x00' '\x24\xfa\xe5\xe0' \
-            '\xf3\xfb\x00\x00' '\xb7\x00\x00\x00' \
-            '\x00\x00\x00\x00'
+        self.req_bin_0 = b'\x37\x00\x00\x1b' b'\x3f\x38\x5c\x6a' \
+            b'\x1b\x3b\x61\xaf' b'\x00\x7f\xff\xff' \
+            b'\x0a\x00\x00\x00' b'\x6b\x22\x80\xb0' \
+            b'\x7c\xfb\xd8\xff' b'\x02\xa4\x83\xa5' \
+            b'\xc5\x3e\x00\x00' b'\x01\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x02\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x04\xa0\x64\xec' b'\x25\xa6\x55\x55' \
+            b'\xcf\x32\x00\x00' b'\xbb\x2d\x00\x00' \
+            b'\x05\xab\x64\x3b' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x82\xd3\x00\x00' \
+            b'\xe3\x05\x00\x00' b'\x24\xfa\xe5\xe0' \
+            b'\xf3\xfb\x00\x00' b'\xb7\x00\x00\x00' \
+            b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CreateGC._request.to_binary, (), self.req_args_0)
+        bin = request.CreateGC._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2832,23 +2840,23 @@
             'attrs': {'dashes': 249, 'fill_rule': 1, 'clip_mask': 496525721, 'plane_mask': 1467281901, 'line_style': 2, 'tile': 1713935374, 'arc_mode': 0, 'clip_y_origin': -24572, 'dash_offset': 46636, 'line_width': 61036, 'background': 1598773587, 'clip_x_origin': -19725, 'join_style': 1, 'graphics_exposures': 0, 'font': 429323306, 'tile_stipple_y_origin': -11767, 'stipple': 1365263649, 'fill_style': 2, 'cap_style': 1, 'subwindow_mode': 1, 'tile_stipple_x_origin': -23501, 'foreground': 1272378077, 'function': 11},
             'gc': 518903558,
             }
-        self.req_bin_0 = '\x38\x00\x00\x1a' '\x1e\xed\xd7\x06' \
-            '\x00\x7f\xff\xff' '\x0b\x00\x00\x00' \
-            '\x57\x74\xf1\xed' '\x4b\xd6\xf2\xdd' \
-            '\x5f\x4b\x59\x53' '\xee\x6c\x00\x00' \
-            '\x02\x00\x00\x00' '\x01\x00\x00\x00' \
-            '\x01\x00\x00\x00' '\x02\x00\x00\x00' \
-            '\x01\x00\x00\x00' '\x66\x28\x94\x0e' \
-            '\x51\x60\x45\x21' '\xa4\x33\x00\x00' \
-            '\xd2\x09\x00\x00' '\x19\x96\xf4\x2a' \
-            '\x01\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\xb2\xf3\x00\x00' '\xa0\x04\x00\x00' \
-            '\x1d\x98\x61\x99' '\xb6\x2c\x00\x00' \
-            '\xf9\x00\x00\x00' '\x00\x00\x00\x00'
+        self.req_bin_0 = b'\x38\x00\x00\x1a' b'\x1e\xed\xd7\x06' \
+            b'\x00\x7f\xff\xff' b'\x0b\x00\x00\x00' \
+            b'\x57\x74\xf1\xed' b'\x4b\xd6\xf2\xdd' \
+            b'\x5f\x4b\x59\x53' b'\xee\x6c\x00\x00' \
+            b'\x02\x00\x00\x00' b'\x01\x00\x00\x00' \
+            b'\x01\x00\x00\x00' b'\x02\x00\x00\x00' \
+            b'\x01\x00\x00\x00' b'\x66\x28\x94\x0e' \
+            b'\x51\x60\x45\x21' b'\xa4\x33\x00\x00' \
+            b'\xd2\x09\x00\x00' b'\x19\x96\xf4\x2a' \
+            b'\x01\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\xb2\xf3\x00\x00' b'\xa0\x04\x00\x00' \
+            b'\x1d\x98\x61\x99' b'\xb6\x2c\x00\x00' \
+            b'\xf9\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangeGC._request.to_binary, (), self.req_args_0)
+        bin = request.ChangeGC._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2873,12 +2881,12 @@
             'src_gc': 1958847367,
             'dst_gc': 1311353896,
             }
-        self.req_bin_0 = '\x39\x00\x00\x04' '\x74\xc1\xa3\x87' \
-            '\x4e\x29\xac\x28' '\x3d\xfc\x5c\x92'
+        self.req_bin_0 = b'\x39\x00\x00\x04' b'\x74\xc1\xa3\x87' \
+            b'\x4e\x29\xac\x28' b'\x3d\xfc\x5c\x92'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CopyGC._request.to_binary, (), self.req_args_0)
+        bin = request.CopyGC._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2903,13 +2911,13 @@
             'dash_offset': 51693,
             'gc': 1639787502,
             }
-        self.req_bin_0 = '\x3a\x00\x00\x06' '\x61\xbd\x2b\xee' \
-            '\xc9\xed\x00\x09' '\xa9\xf1\x9e\xee' \
-            '\xad\x9f\xb6\x8b' '\x8b\x00\x00\x00'
+        self.req_bin_0 = b'\x3a\x00\x00\x06' b'\x61\xbd\x2b\xee' \
+            b'\xc9\xed\x00\x09' b'\xa9\xf1\x9e\xee' \
+            b'\xad\x9f\xb6\x8b' b'\x8b\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetDashes._request.to_binary, (), self.req_args_0)
+        bin = request.SetDashes._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2936,10 +2944,10 @@
             'y_origin': -16557,
             'ordering': 3,
             }
-        self.req_bin_0 = '\x3b\x03\x00\x07' '\x41\xe7\x44\x74' \
-            '\xa7\x18\xbf\x53' '\xc3\xba\xf4\x3f' \
-            '\xb6\x51\xe7\xff' '\xc9\x22\x9e\xe7' \
-            '\x1e\x66\x26\x9b'
+        self.req_bin_0 = b'\x3b\x03\x00\x07' b'\x41\xe7\x44\x74' \
+            b'\xa7\x18\xbf\x53' b'\xc3\xba\xf4\x3f' \
+            b'\xb6\x51\xe7\xff' b'\xc9\x22\x9e\xe7' \
+            b'\x1e\x66\x26\x9b'
 
         self.req_args_1 = {
             'rectangles': [],
@@ -2948,12 +2956,12 @@
             'y_origin': -10293,
             'ordering': 0,
             }
-        self.req_bin_1 = '\x3b\x00\x00\x03' '\x11\x60\x29\xbb' \
-            '\x8b\x55\xd7\xcb'
+        self.req_bin_1 = b'\x3b\x00\x00\x03' b'\x11\x60\x29\xbb' \
+            b'\x8b\x55\xd7\xcb'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetClipRectangles._request.to_binary, (), self.req_args_0)
+        bin = request.SetClipRectangles._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2971,7 +2979,7 @@
             raise AssertionError(args)
 
     def testPackRequest1(self):
-        bin = apply(request.SetClipRectangles._request.to_binary, (), self.req_args_1)
+        bin = request.SetClipRectangles._request.to_binary(*(), **self.req_args_1)
         try:
             assert bin == self.req_bin_1
         except AssertionError:
@@ -2994,11 +3002,11 @@
         self.req_args_0 = {
             'gc': 371787524,
             }
-        self.req_bin_0 = '\x3c\x00\x00\x02' '\x16\x29\x07\x04'
+        self.req_bin_0 = b'\x3c\x00\x00\x02' b'\x16\x29\x07\x04'
 
 
     def testPackRequest0(self):
-        bin = apply(request.FreeGC._request.to_binary, (), self.req_args_0)
+        bin = request.FreeGC._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3026,12 +3034,12 @@
             'x': -1843,
             'y': -32148,
             }
-        self.req_bin_0 = '\x3d\x00\x00\x04' '\x4a\xbe\x68\xe1' \
-            '\xf8\xcd\x82\x6c' '\xf9\x4d\xd2\x10'
+        self.req_bin_0 = b'\x3d\x00\x00\x04' b'\x4a\xbe\x68\xe1' \
+            b'\xf8\xcd\x82\x6c' b'\xf9\x4d\xd2\x10'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ClearArea._request.to_binary, (), self.req_args_0)
+        bin = request.ClearArea._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3062,14 +3070,14 @@
             'dst_x': -19068,
             'dst_y': -4602,
             }
-        self.req_bin_0 = '\x3e\x00\x00\x07' '\x13\x2d\x11\x29' \
-            '\x0f\x05\x83\xf1' '\x07\x83\xb2\x60' \
-            '\x9c\x38\xdf\x4c' '\xb5\x84\xee\x06' \
-            '\xc1\x06\xf0\x3e'
+        self.req_bin_0 = b'\x3e\x00\x00\x07' b'\x13\x2d\x11\x29' \
+            b'\x0f\x05\x83\xf1' b'\x07\x83\xb2\x60' \
+            b'\x9c\x38\xdf\x4c' b'\xb5\x84\xee\x06' \
+            b'\xc1\x06\xf0\x3e'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CopyArea._request.to_binary, (), self.req_args_0)
+        bin = request.CopyArea._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3101,14 +3109,14 @@
             'dst_x': -24940,
             'dst_y': -13009,
             }
-        self.req_bin_0 = '\x3f\x00\x00\x08' '\x76\x88\x65\x19' \
-            '\x7e\x6a\x2e\xa4' '\x4b\x78\x61\xdd' \
-            '\xee\x42\xa8\x7f' '\x9e\x94\xcd\x2f' \
-            '\xa1\x19\x83\xfb' '\x7a\x50\x0a\x28'
+        self.req_bin_0 = b'\x3f\x00\x00\x08' b'\x76\x88\x65\x19' \
+            b'\x7e\x6a\x2e\xa4' b'\x4b\x78\x61\xdd' \
+            b'\xee\x42\xa8\x7f' b'\x9e\x94\xcd\x2f' \
+            b'\xa1\x19\x83\xfb' b'\x7a\x50\x0a\x28'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CopyPlane._request.to_binary, (), self.req_args_0)
+        bin = request.CopyPlane._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3134,13 +3142,13 @@
             'drawable': 1008674,
             'coord_mode': 1,
             }
-        self.req_bin_0 = '\x40\x01\x00\x06' '\x00\x0f\x64\x22' \
-            '\x0c\x4b\x61\x09' '\xa8\x4f\xbe\xb6' \
-            '\xbf\xaf\xcd\xce' '\xb3\x60\xcc\xb5'
+        self.req_bin_0 = b'\x40\x01\x00\x06' b'\x00\x0f\x64\x22' \
+            b'\x0c\x4b\x61\x09' b'\xa8\x4f\xbe\xb6' \
+            b'\xbf\xaf\xcd\xce' b'\xb3\x60\xcc\xb5'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolyPoint._request.to_binary, (), self.req_args_0)
+        bin = request.PolyPoint._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3166,14 +3174,14 @@
             'drawable': 1668889192,
             'coord_mode': 1,
             }
-        self.req_bin_0 = '\x41\x01\x00\x08' '\x63\x79\x3a\x68' \
-            '\x50\xcc\xb9\xcd' '\xd2\x21\xb6\xa3' \
-            '\xac\x83\xa7\x3e' '\xbb\x55\xca\x7d' \
-            '\x98\x4f\xb4\x67' '\xd1\xfd\x98\x88'
+        self.req_bin_0 = b'\x41\x01\x00\x08' b'\x63\x79\x3a\x68' \
+            b'\x50\xcc\xb9\xcd' b'\xd2\x21\xb6\xa3' \
+            b'\xac\x83\xa7\x3e' b'\xbb\x55\xca\x7d' \
+            b'\x98\x4f\xb4\x67' b'\xd1\xfd\x98\x88'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolyLine._request.to_binary, (), self.req_args_0)
+        bin = request.PolyLine._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3198,13 +3206,13 @@
             'drawable': 146511635,
             'gc': 53385255,
             }
-        self.req_bin_0 = '\x42\x00\x00\x05' '\x08\xbb\x97\x13' \
-            '\x03\x2e\x98\x27' '\xce\xbe\xa1\x44' \
-            '\x9b\x56\xa8\x05'
+        self.req_bin_0 = b'\x42\x00\x00\x05' b'\x08\xbb\x97\x13' \
+            b'\x03\x2e\x98\x27' b'\xce\xbe\xa1\x44' \
+            b'\x9b\x56\xa8\x05'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolySegment._request.to_binary, (), self.req_args_0)
+        bin = request.PolySegment._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3229,15 +3237,15 @@
             'gc': 410140275,
             'rectangles': [{'height': 63567, 'x': -16992, 'width': 11122, 'y': -21320}, {'height': 34652, 'x': -18051, 'width': 59622, 'y': -30426}, {'height': 45646, 'x': -1111, 'width': 46231, 'y': -25261}],
             }
-        self.req_bin_0 = '\x43\x00\x00\x09' '\x72\xe3\x09\x3d' \
-            '\x18\x72\x3e\x73' '\xbd\xa0\xac\xb8' \
-            '\x2b\x72\xf8\x4f' '\xb9\x7d\x89\x26' \
-            '\xe8\xe6\x87\x5c' '\xfb\xa9\x9d\x53' \
-            '\xb4\x97\xb2\x4e'
+        self.req_bin_0 = b'\x43\x00\x00\x09' b'\x72\xe3\x09\x3d' \
+            b'\x18\x72\x3e\x73' b'\xbd\xa0\xac\xb8' \
+            b'\x2b\x72\xf8\x4f' b'\xb9\x7d\x89\x26' \
+            b'\xe8\xe6\x87\x5c' b'\xfb\xa9\x9d\x53' \
+            b'\xb4\x97\xb2\x4e'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolyRectangle._request.to_binary, (), self.req_args_0)
+        bin = request.PolyRectangle._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3262,16 +3270,16 @@
             'drawable': 718777148,
             'gc': 1127021391,
             }
-        self.req_bin_0 = '\x44\x00\x00\x0c' '\x2a\xd7\xab\x3c' \
-            '\x43\x2c\xfb\x4f' '\xec\xb1\xdc\x0b' \
-            '\xff\xa8\x92\xad' '\xbd\xad\x9b\xce' \
-            '\xc9\xd7\xa6\xb2' '\xf2\xdd\x24\x6a' \
-            '\xae\xd3\xde\xce' '\xce\x6b\xe2\x82' \
-            '\xf8\xf4\xf7\x22' '\xfb\x31\xfc\xd7'
+        self.req_bin_0 = b'\x44\x00\x00\x0c' b'\x2a\xd7\xab\x3c' \
+            b'\x43\x2c\xfb\x4f' b'\xec\xb1\xdc\x0b' \
+            b'\xff\xa8\x92\xad' b'\xbd\xad\x9b\xce' \
+            b'\xc9\xd7\xa6\xb2' b'\xf2\xdd\x24\x6a' \
+            b'\xae\xd3\xde\xce' b'\xce\x6b\xe2\x82' \
+            b'\xf8\xf4\xf7\x22' b'\xfb\x31\xfc\xd7'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolyArc._request.to_binary, (), self.req_args_0)
+        bin = request.PolyArc._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3298,14 +3306,14 @@
             'drawable': 1326525185,
             'coord_mode': 0,
             }
-        self.req_bin_0 = '\x45\x00\x00\x07' '\x4f\x11\x2b\x01' \
-            '\x3f\xce\x79\x1a' '\x01\x00\x00\x00' \
-            '\xb6\xc3\xb4\x29' '\xdd\x38\x96\xbc' \
-            '\xcb\xe8\xdb\x0a'
+        self.req_bin_0 = b'\x45\x00\x00\x07' b'\x4f\x11\x2b\x01' \
+            b'\x3f\xce\x79\x1a' b'\x01\x00\x00\x00' \
+            b'\xb6\xc3\xb4\x29' b'\xdd\x38\x96\xbc' \
+            b'\xcb\xe8\xdb\x0a'
 
 
     def testPackRequest0(self):
-        bin = apply(request.FillPoly._request.to_binary, (), self.req_args_0)
+        bin = request.FillPoly._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3330,14 +3338,14 @@
             'gc': 1965498255,
             'rectangles': [{'height': 36920, 'x': -2965, 'width': 26437, 'y': -3568}, {'height': 44383, 'x': -18327, 'width': 37730, 'y': -26752}],
             }
-        self.req_bin_0 = '\x46\x00\x00\x07' '\x65\xd8\x42\xcc' \
-            '\x75\x27\x1f\x8f' '\xf4\x6b\xf2\x10' \
-            '\x67\x45\x90\x38' '\xb8\x69\x97\x80' \
-            '\x93\x62\xad\x5f'
+        self.req_bin_0 = b'\x46\x00\x00\x07' b'\x65\xd8\x42\xcc' \
+            b'\x75\x27\x1f\x8f' b'\xf4\x6b\xf2\x10' \
+            b'\x67\x45\x90\x38' b'\xb8\x69\x97\x80' \
+            b'\x93\x62\xad\x5f'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolyFillRectangle._request.to_binary, (), self.req_args_0)
+        bin = request.PolyFillRectangle._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3362,13 +3370,13 @@
             'drawable': 2083870696,
             'gc': 414470877,
             }
-        self.req_bin_0 = '\x47\x00\x00\x06' '\x7c\x35\x57\xe8' \
-            '\x18\xb4\x52\xdd' '\xd5\xfe\xb3\x9d' \
-            '\xd2\x3b\xfa\x72' '\x91\x38\xe5\xc8'
+        self.req_bin_0 = b'\x47\x00\x00\x06' b'\x7c\x35\x57\xe8' \
+            b'\x18\xb4\x52\xdd' b'\xd5\xfe\xb3\x9d' \
+            b'\xd2\x3b\xfa\x72' b'\x91\x38\xe5\xc8'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolyFillArc._request.to_binary, (), self.req_args_0)
+        bin = request.PolyFillArc._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3400,15 +3408,15 @@
             'width': 62850,
             'dst_y': -30693,
             }
-        self.req_bin_0 = '\x48\x01\x00\x09' '\x5b\x79\x56\xff' \
-            '\x0c\x83\x06\x83' '\xf5\x82\x26\x9b' \
-            '\xf3\x2c\x88\x1b' '\x93\xad\x00\x00' \
-            '\x62\x69\x74\x20' '\x6d\x61\x70\x20' \
-            '\x64\x61\x74\x61'
+        self.req_bin_0 = b'\x48\x01\x00\x09' b'\x5b\x79\x56\xff' \
+            b'\x0c\x83\x06\x83' b'\xf5\x82\x26\x9b' \
+            b'\xf3\x2c\x88\x1b' b'\x93\xad\x00\x00' \
+            b'\x62\x69\x74\x20' b'\x6d\x61\x70\x20' \
+            b'\x64\x61\x74\x61'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PutImage._request.to_binary, (), self.req_args_0)
+        bin = request.PutImage._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3437,9 +3445,9 @@
             'format': 1,
             'width': 58993,
             }
-        self.req_bin_0 = '\x49\x01\x00\x05' '\x4f\x3e\x5f\x83' \
-            '\x93\xe8\x87\x75' '\xe6\x71\xa6\xa1' \
-            '\x68\xae\xae\x00'
+        self.req_bin_0 = b'\x49\x01\x00\x05' b'\x4f\x3e\x5f\x83' \
+            b'\x93\xe8\x87\x75' b'\xe6\x71\xa6\xa1' \
+            b'\x68\xae\xae\x00'
 
         self.reply_args_0 = {
             'sequence_number': 54997,
@@ -3447,18 +3455,18 @@
             'visual': 1108632607,
             'depth': 181,
             }
-        self.reply_bin_0 = '\x01\xb5\xd6\xd5' '\x00\x00\x00\x07' \
-            '\x42\x14\x64\x1f' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x74\x68\x69\x73' '\x20\x69\x73\x20' \
-            '\x72\x65\x61\x6c' '\x20\x6c\x79\x20' \
-            '\x69\x6d\x61\x67' '\x20\x65\x20\x62' \
-            '\x2d\x6d\x61\x70'
+        self.reply_bin_0 = b'\x01\xb5\xd6\xd5' b'\x00\x00\x00\x07' \
+            b'\x42\x14\x64\x1f' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x74\x68\x69\x73' b'\x20\x69\x73\x20' \
+            b'\x72\x65\x61\x6c' b'\x20\x6c\x79\x20' \
+            b'\x69\x6d\x61\x67' b'\x20\x65\x20\x62' \
+            b'\x2d\x6d\x61\x70'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetImage._request.to_binary, (), self.req_args_0)
+        bin = request.GetImage._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3476,7 +3484,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetImage._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetImage._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -3503,14 +3511,14 @@
             'items': [{'delta': 2, 'string': 'zoo'}, 16909060, {'delta': 0, 'string': 'ie'}],
             'y': -8902,
             }
-        self.req_bin_0 = '\x4a\x00\x00\x08' '\x5c\x72\x5c\x8a' \
-            '\x58\x4e\xe2\x69' '\xcb\x14\xdd\x3a' \
-            '\x03\x02\x7a\x6f' '\x6f\xff\x01\x02' \
-            '\x03\x04\x02\x00' '\x69\x65\x00\x00'
+        self.req_bin_0 = b'\x4a\x00\x00\x08' b'\x5c\x72\x5c\x8a' \
+            b'\x58\x4e\xe2\x69' b'\xcb\x14\xdd\x3a' \
+            b'\x03\x02\x7a\x6f' b'\x6f\xff\x01\x02' \
+            b'\x03\x04\x02\x00' b'\x69\x65\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolyText8._request.to_binary, (), self.req_args_0)
+        bin = request.PolyText8._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3537,14 +3545,14 @@
             'items': [{'delta': 2, 'string': (4131, 18)}, 16909060],
             'y': -2741,
             }
-        self.req_bin_0 = '\x4b\x00\x00\x07' '\x5e\xda\xf1\xf4' \
-            '\x17\xe2\x28\x18' '\x84\x82\xf5\x4b' \
-            '\x02\x02\x10\x23' '\x00\x12\xff\x01' \
-            '\x02\x03\x04\x00'
+        self.req_bin_0 = b'\x4b\x00\x00\x07' b'\x5e\xda\xf1\xf4' \
+            b'\x17\xe2\x28\x18' b'\x84\x82\xf5\x4b' \
+            b'\x02\x02\x10\x23' b'\x00\x12\xff\x01' \
+            b'\x02\x03\x04\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolyText16._request.to_binary, (), self.req_args_0)
+        bin = request.PolyText16._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3571,13 +3579,13 @@
             'x': -16077,
             'y': -4873,
             }
-        self.req_bin_0 = '\x4c\x06\x00\x06' '\x6c\xb1\xdd\x5d' \
-            '\x53\x10\x80\x21' '\xc1\x33\xec\xf7' \
-            '\x73\x68\x6f\x77' '\x6d\x65\x00\x00'
+        self.req_bin_0 = b'\x4c\x06\x00\x06' b'\x6c\xb1\xdd\x5d' \
+            b'\x53\x10\x80\x21' b'\xc1\x33\xec\xf7' \
+            b'\x73\x68\x6f\x77' b'\x6d\x65\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ImageText8._request.to_binary, (), self.req_args_0)
+        bin = request.ImageText8._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3604,14 +3612,14 @@
             'x': -21343,
             'y': -24237,
             }
-        self.req_bin_0 = '\x4d\x08\x00\x08' '\x02\x00\xce\x10' \
-            '\x65\x77\x08\xde' '\xac\xa1\xa1\x53' \
-            '\x00\x73\x00\x68' '\x00\x6f\x00\x77' \
-            '\x00\x6d\x00\x6f' '\x00\x72\x00\x65'
+        self.req_bin_0 = b'\x4d\x08\x00\x08' b'\x02\x00\xce\x10' \
+            b'\x65\x77\x08\xde' b'\xac\xa1\xa1\x53' \
+            b'\x00\x73\x00\x68' b'\x00\x6f\x00\x77' \
+            b'\x00\x6d\x00\x6f' b'\x00\x72\x00\x65'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ImageText16._request.to_binary, (), self.req_args_0)
+        bin = request.ImageText16._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3637,12 +3645,12 @@
             'visual': 813982403,
             'window': 698475631,
             }
-        self.req_bin_0 = '\x4e\x00\x00\x04' '\x09\x63\xd1\xab' \
-            '\x29\xa1\xe4\x6f' '\x30\x84\x62\xc3'
+        self.req_bin_0 = b'\x4e\x00\x00\x04' b'\x09\x63\xd1\xab' \
+            b'\x29\xa1\xe4\x6f' b'\x30\x84\x62\xc3'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CreateColormap._request.to_binary, (), self.req_args_0)
+        bin = request.CreateColormap._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3665,11 +3673,11 @@
         self.req_args_0 = {
             'cmap': 1296514923,
             }
-        self.req_bin_0 = '\x4f\x00\x00\x02' '\x4d\x47\x3f\x6b'
+        self.req_bin_0 = b'\x4f\x00\x00\x02' b'\x4d\x47\x3f\x6b'
 
 
     def testPackRequest0(self):
-        bin = apply(request.FreeColormap._request.to_binary, (), self.req_args_0)
+        bin = request.FreeColormap._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3693,12 +3701,12 @@
             'src_cmap': 1049336329,
             'mid': 1237242690,
             }
-        self.req_bin_0 = '\x50\x00\x00\x03' '\x49\xbe\xd3\x42' \
-            '\x3e\x8b\x9a\x09'
+        self.req_bin_0 = b'\x50\x00\x00\x03' b'\x49\xbe\xd3\x42' \
+            b'\x3e\x8b\x9a\x09'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CopyColormapAndFree._request.to_binary, (), self.req_args_0)
+        bin = request.CopyColormapAndFree._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3721,11 +3729,11 @@
         self.req_args_0 = {
             'cmap': 1539075582,
             }
-        self.req_bin_0 = '\x51\x00\x00\x02' '\x5b\xbc\x6d\xfe'
+        self.req_bin_0 = b'\x51\x00\x00\x02' b'\x5b\xbc\x6d\xfe'
 
 
     def testPackRequest0(self):
-        bin = apply(request.InstallColormap._request.to_binary, (), self.req_args_0)
+        bin = request.InstallColormap._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3748,11 +3756,11 @@
         self.req_args_0 = {
             'cmap': 959493342,
             }
-        self.req_bin_0 = '\x52\x00\x00\x02' '\x39\x30\xb4\xde'
+        self.req_bin_0 = b'\x52\x00\x00\x02' b'\x39\x30\xb4\xde'
 
 
     def testPackRequest0(self):
-        bin = apply(request.UninstallColormap._request.to_binary, (), self.req_args_0)
+        bin = request.UninstallColormap._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3775,21 +3783,21 @@
         self.req_args_0 = {
             'window': 1517864638,
             }
-        self.req_bin_0 = '\x53\x00\x00\x02' '\x5a\x78\xc6\xbe'
+        self.req_bin_0 = b'\x53\x00\x00\x02' b'\x5a\x78\xc6\xbe'
 
         self.reply_args_0 = {
             'cmaps': [2146327722, 1361260227],
             'sequence_number': 61652,
             }
-        self.reply_bin_0 = '\x01\x00\xf0\xd4' '\x00\x00\x00\x02' \
-            '\x00\x02\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x7f\xee\x5c\xaa' '\x51\x23\x2e\xc3'
+        self.reply_bin_0 = b'\x01\x00\xf0\xd4' b'\x00\x00\x00\x02' \
+            b'\x00\x02\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x7f\xee\x5c\xaa' b'\x51\x23\x2e\xc3'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ListInstalledColormaps._request.to_binary, (), self.req_args_0)
+        bin = request.ListInstalledColormaps._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3807,7 +3815,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.ListInstalledColormaps._reply.to_binary, (), self.reply_args_0)
+        bin = request.ListInstalledColormaps._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -3833,8 +3841,8 @@
             'cmap': 523356125,
             'blue': 49580,
             }
-        self.req_bin_0 = '\x54\x00\x00\x04' '\x1f\x31\xc7\xdd' \
-            '\x9b\x2d\xc2\xbe' '\xc1\xac\x00\x00'
+        self.req_bin_0 = b'\x54\x00\x00\x04' b'\x1f\x31\xc7\xdd' \
+            b'\x9b\x2d\xc2\xbe' b'\xc1\xac\x00\x00'
 
         self.reply_args_0 = {
             'sequence_number': 10904,
@@ -3843,14 +3851,14 @@
             'pixel': 1067923656,
             'blue': 14525,
             }
-        self.reply_bin_0 = '\x01\x00\x2a\x98' '\x00\x00\x00\x00' \
-            '\xab\x08\x0c\x62' '\x38\xbd\x00\x00' \
-            '\x3f\xa7\x38\xc8' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\x2a\x98' b'\x00\x00\x00\x00' \
+            b'\xab\x08\x0c\x62' b'\x38\xbd\x00\x00' \
+            b'\x3f\xa7\x38\xc8' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.AllocColor._request.to_binary, (), self.req_args_0)
+        bin = request.AllocColor._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3868,7 +3876,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.AllocColor._reply.to_binary, (), self.reply_args_0)
+        bin = request.AllocColor._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -3892,9 +3900,9 @@
             'cmap': 128217824,
             'name': 'octarin',
             }
-        self.req_bin_0 = '\x55\x00\x00\x05' '\x07\xa4\x72\xe0' \
-            '\x00\x07\x00\x00' '\x6f\x63\x74\x61' \
-            '\x72\x69\x6e\x00'
+        self.req_bin_0 = b'\x55\x00\x00\x05' b'\x07\xa4\x72\xe0' \
+            b'\x00\x07\x00\x00' b'\x6f\x63\x74\x61' \
+            b'\x72\x69\x6e\x00'
 
         self.reply_args_0 = {
             'sequence_number': 19971,
@@ -3906,14 +3914,14 @@
             'screen_blue': 43109,
             'exact_red': 64213,
             }
-        self.reply_bin_0 = '\x01\x00\x4e\x03' '\x00\x00\x00\x00' \
-            '\x4e\xee\x49\x76' '\xfa\xd5\x71\x8b' \
-            '\xe5\xbb\x82\x63' '\xc5\x43\xa8\x65' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\x4e\x03' b'\x00\x00\x00\x00' \
+            b'\x4e\xee\x49\x76' b'\xfa\xd5\x71\x8b' \
+            b'\xe5\xbb\x82\x63' b'\xc5\x43\xa8\x65' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.AllocNamedColor._request.to_binary, (), self.req_args_0)
+        bin = request.AllocNamedColor._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3931,7 +3939,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.AllocNamedColor._reply.to_binary, (), self.reply_args_0)
+        bin = request.AllocNamedColor._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -3957,42 +3965,42 @@
             'cmap': 675372338,
             'contiguous': 1,
             }
-        self.req_bin_0 = '\x56\x01\x00\x03' '\x28\x41\x5d\x32' \
-            '\xe5\x4a\x80\x63'
+        self.req_bin_0 = b'\x56\x01\x00\x03' b'\x28\x41\x5d\x32' \
+            b'\xe5\x4a\x80\x63'
 
         self.reply_args_0 = {
             'masks': [733927381, 1023311668, 595898647],
             'pixels': [693075497, 1294879029, 1478712895, 1781963728, 1442185575, 1654003869, 787619123, 1049825849, 1773935772, 1689075922, 1626562257, 177731275, 661046122, 1970509470, 1918486395, 688539096, 41044851],
             'sequence_number': 54025,
             }
-        self.reply_bin_0 = '\x01\x00\xd3\x09' '\x00\x00\x00\x14' \
-            '\x00\x11\x00\x03' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x29\x4f\x7e\x29' '\x4d\x2e\x49\x35' \
-            '\x58\x23\x5e\x3f' '\x6a\x36\x9b\xd0' \
-            '\x55\xf6\x01\x67' '\x62\x96\x18\x9d' \
-            '\x2e\xf2\x1d\x33' '\x3e\x93\x12\x39' \
-            '\x69\xbc\x1c\x9c' '\x64\xad\x40\xd2' \
-            '\x60\xf3\x5e\xd1' '\x0a\x97\xf6\xcb' \
-            '\x27\x66\xc3\x6a' '\x75\x73\x96\x9e' \
-            '\x72\x59\xc7\x7b' '\x29\x0a\x45\xd8' \
-            '\x02\x72\x4b\x73' '\x2b\xbe\xd7\xd5' \
-            '\x3c\xfe\x7f\x34' '\x23\x84\xb1\x17'
+        self.reply_bin_0 = b'\x01\x00\xd3\x09' b'\x00\x00\x00\x14' \
+            b'\x00\x11\x00\x03' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x29\x4f\x7e\x29' b'\x4d\x2e\x49\x35' \
+            b'\x58\x23\x5e\x3f' b'\x6a\x36\x9b\xd0' \
+            b'\x55\xf6\x01\x67' b'\x62\x96\x18\x9d' \
+            b'\x2e\xf2\x1d\x33' b'\x3e\x93\x12\x39' \
+            b'\x69\xbc\x1c\x9c' b'\x64\xad\x40\xd2' \
+            b'\x60\xf3\x5e\xd1' b'\x0a\x97\xf6\xcb' \
+            b'\x27\x66\xc3\x6a' b'\x75\x73\x96\x9e' \
+            b'\x72\x59\xc7\x7b' b'\x29\x0a\x45\xd8' \
+            b'\x02\x72\x4b\x73' b'\x2b\xbe\xd7\xd5' \
+            b'\x3c\xfe\x7f\x34' b'\x23\x84\xb1\x17'
 
         self.reply_args_1 = {
             'masks': [],
             'pixels': [],
             'sequence_number': 6273,
             }
-        self.reply_bin_1 = '\x01\x00\x18\x81' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_1 = b'\x01\x00\x18\x81' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.AllocColorCells._request.to_binary, (), self.req_args_0)
+        bin = request.AllocColorCells._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4010,7 +4018,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.AllocColorCells._reply.to_binary, (), self.reply_args_0)
+        bin = request.AllocColorCells._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4028,7 +4036,7 @@
             raise AssertionError(args)
 
     def testPackReply1(self):
-        bin = apply(request.AllocColorCells._reply.to_binary, (), self.reply_args_1)
+        bin = request.AllocColorCells._reply.to_binary(*(), **self.reply_args_1)
         try:
             assert bin == self.reply_bin_1
         except AssertionError:
@@ -4056,8 +4064,8 @@
             'contiguous': 0,
             'blue': 23880,
             }
-        self.req_bin_0 = '\x57\x00\x00\x04' '\x12\x5c\x02\x63' \
-            '\xe3\xa3\x59\x5c' '\x24\xd1\x5d\x48'
+        self.req_bin_0 = b'\x57\x00\x00\x04' b'\x12\x5c\x02\x63' \
+            b'\xe3\xa3\x59\x5c' b'\x24\xd1\x5d\x48'
 
         self.reply_args_0 = {
             'green_mask': 265888391,
@@ -4066,16 +4074,16 @@
             'blue_mask': 44676180,
             'red_mask': 734623206,
             }
-        self.reply_bin_0 = '\x01\x00\x8d\x4f' '\x00\x00\x00\x04' \
-            '\x00\x04\x00\x00' '\x2b\xc9\x75\xe6' \
-            '\x0f\xd9\x22\x87' '\x02\xa9\xb4\x54' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x1d\x52\xbe\x09' '\x4d\x99\x83\xbe' \
-            '\x5f\xa5\xda\xfd' '\x54\x90\x6c\x90'
+        self.reply_bin_0 = b'\x01\x00\x8d\x4f' b'\x00\x00\x00\x04' \
+            b'\x00\x04\x00\x00' b'\x2b\xc9\x75\xe6' \
+            b'\x0f\xd9\x22\x87' b'\x02\xa9\xb4\x54' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x1d\x52\xbe\x09' b'\x4d\x99\x83\xbe' \
+            b'\x5f\xa5\xda\xfd' b'\x54\x90\x6c\x90'
 
 
     def testPackRequest0(self):
-        bin = apply(request.AllocColorPlanes._request.to_binary, (), self.req_args_0)
+        bin = request.AllocColorPlanes._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4093,7 +4101,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.AllocColorPlanes._reply.to_binary, (), self.reply_args_0)
+        bin = request.AllocColorPlanes._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4118,20 +4126,20 @@
             'pixels': [61281082, 398475082, 1660604639, 1516738417, 1211104329, 105034864, 884930615, 902914796, 288637231, 2097165249, 1171127263, 1027274519, 806213035, 1485898709, 542709465, 169067149, 1230881159],
             'plane_mask': 1204733200,
             }
-        self.req_bin_0 = '\x58\x00\x00\x14' '\x2b\x55\x43\xd8' \
-            '\x47\xce\xc5\x10' '\x03\xa7\x13\x3a' \
-            '\x17\xc0\x3f\x4a' '\x62\xfa\xd0\xdf' \
-            '\x5a\x67\x97\x71' '\x48\x2f\xfc\x49' \
-            '\x06\x42\xb4\x70' '\x34\xbe\xf8\x37' \
-            '\x35\xd1\x62\xec' '\x11\x34\x41\x2f' \
-            '\x7d\x00\x33\xc1' '\x45\xcd\xfb\xdf' \
-            '\x3d\x3a\xf7\x17' '\x30\x0d\xd5\xab' \
-            '\x58\x91\x03\xd5' '\x20\x59\x16\xd9' \
-            '\x0a\x13\xc2\x8d' '\x49\x5d\xc1\x87'
+        self.req_bin_0 = b'\x58\x00\x00\x14' b'\x2b\x55\x43\xd8' \
+            b'\x47\xce\xc5\x10' b'\x03\xa7\x13\x3a' \
+            b'\x17\xc0\x3f\x4a' b'\x62\xfa\xd0\xdf' \
+            b'\x5a\x67\x97\x71' b'\x48\x2f\xfc\x49' \
+            b'\x06\x42\xb4\x70' b'\x34\xbe\xf8\x37' \
+            b'\x35\xd1\x62\xec' b'\x11\x34\x41\x2f' \
+            b'\x7d\x00\x33\xc1' b'\x45\xcd\xfb\xdf' \
+            b'\x3d\x3a\xf7\x17' b'\x30\x0d\xd5\xab' \
+            b'\x58\x91\x03\xd5' b'\x20\x59\x16\xd9' \
+            b'\x0a\x13\xc2\x8d' b'\x49\x5d\xc1\x87'
 
 
     def testPackRequest0(self):
-        bin = apply(request.FreeColors._request.to_binary, (), self.req_args_0)
+        bin = request.FreeColors._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4155,17 +4163,17 @@
             'cmap': 501035281,
             'items': [{'red': 27925, 'pixel': 1094971765, 'green': 3673, 'flags': 189, 'blue': 31593}, {'red': 41633, 'pixel': 1330003189, 'green': 56186, 'flags': 178, 'blue': 30263}, {'red': 36007, 'pixel': 1813524037, 'green': 29697, 'flags': 224, 'blue': 14071}, {'red': 45716, 'pixel': 1987610486, 'green': 55405, 'flags': 200, 'blue': 35734}],
             }
-        self.req_bin_0 = '\x59\x00\x00\x0e' '\x1d\xdd\x31\x11' \
-            '\x41\x43\xf1\x75' '\x6d\x15\x0e\x59' \
-            '\x7b\x69\xbd\x00' '\x4f\x46\x3c\xf5' \
-            '\xa2\xa1\xdb\x7a' '\x76\x37\xb2\x00' \
-            '\x6c\x18\x2e\x45' '\x8c\xa7\x74\x01' \
-            '\x36\xf7\xe0\x00' '\x76\x78\x87\x76' \
-            '\xb2\x94\xd8\x6d' '\x8b\x96\xc8\x00'
+        self.req_bin_0 = b'\x59\x00\x00\x0e' b'\x1d\xdd\x31\x11' \
+            b'\x41\x43\xf1\x75' b'\x6d\x15\x0e\x59' \
+            b'\x7b\x69\xbd\x00' b'\x4f\x46\x3c\xf5' \
+            b'\xa2\xa1\xdb\x7a' b'\x76\x37\xb2\x00' \
+            b'\x6c\x18\x2e\x45' b'\x8c\xa7\x74\x01' \
+            b'\x36\xf7\xe0\x00' b'\x76\x78\x87\x76' \
+            b'\xb2\x94\xd8\x6d' b'\x8b\x96\xc8\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.StoreColors._request.to_binary, (), self.req_args_0)
+        bin = request.StoreColors._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4191,13 +4199,13 @@
             'cmap': 2061119590,
             'pixel': 1846011298,
             }
-        self.req_bin_0 = '\x5a\xba\x00\x05' '\x7a\xda\x30\x66' \
-            '\x6e\x07\xe5\xa2' '\x00\x04\x00\x00' \
-            '\x62\x6c\x75\x65'
+        self.req_bin_0 = b'\x5a\xba\x00\x05' b'\x7a\xda\x30\x66' \
+            b'\x6e\x07\xe5\xa2' b'\x00\x04\x00\x00' \
+            b'\x62\x6c\x75\x65'
 
 
     def testPackRequest0(self):
-        bin = apply(request.StoreNamedColor._request.to_binary, (), self.req_args_0)
+        bin = request.StoreNamedColor._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4221,35 +4229,35 @@
             'cmap': 596369797,
             'pixels': [1018587496, 1553480933, 952694607, 341816269, 306591348, 1178729919, 173027853, 875811363],
             }
-        self.req_bin_0 = '\x5b\x00\x00\x0a' '\x23\x8b\xe1\x85' \
-            '\x3c\xb6\x69\x68' '\x5c\x98\x3c\xe5' \
-            '\x38\xc8\xf7\x4f' '\x14\x5f\xb3\xcd' \
-            '\x12\x46\x36\x74' '\x46\x41\xfd\xbf' \
-            '\x0a\x50\x32\x0d' '\x34\x33\xd2\x23'
+        self.req_bin_0 = b'\x5b\x00\x00\x0a' b'\x23\x8b\xe1\x85' \
+            b'\x3c\xb6\x69\x68' b'\x5c\x98\x3c\xe5' \
+            b'\x38\xc8\xf7\x4f' b'\x14\x5f\xb3\xcd' \
+            b'\x12\x46\x36\x74' b'\x46\x41\xfd\xbf' \
+            b'\x0a\x50\x32\x0d' b'\x34\x33\xd2\x23'
 
         self.reply_args_0 = {
             'colors': [{'red': 6715, 'blue': 40144, 'green': 56664}, {'red': 5799, 'blue': 22078, 'green': 35523}, {'red': 60111, 'blue': 58654, 'green': 25206}, {'red': 7433, 'blue': 60908, 'green': 14468}, {'red': 31213, 'blue': 9298, 'green': 27481}],
             'sequence_number': 60323,
             }
-        self.reply_bin_0 = '\x01\x00\xeb\xa3' '\x00\x00\x00\x0a' \
-            '\x00\x05\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x1a\x3b\xdd\x58' '\x9c\xd0\x00\x00' \
-            '\x16\xa7\x8a\xc3' '\x56\x3e\x00\x00' \
-            '\xea\xcf\x62\x76' '\xe5\x1e\x00\x00' \
-            '\x1d\x09\x38\x84' '\xed\xec\x00\x00' \
-            '\x79\xed\x6b\x59' '\x24\x52\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\xeb\xa3' b'\x00\x00\x00\x0a' \
+            b'\x00\x05\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x1a\x3b\xdd\x58' b'\x9c\xd0\x00\x00' \
+            b'\x16\xa7\x8a\xc3' b'\x56\x3e\x00\x00' \
+            b'\xea\xcf\x62\x76' b'\xe5\x1e\x00\x00' \
+            b'\x1d\x09\x38\x84' b'\xed\xec\x00\x00' \
+            b'\x79\xed\x6b\x59' b'\x24\x52\x00\x00'
 
         self.req_args_1 = {
             'cmap': 79317049,
             'pixels': [],
             }
-        self.req_bin_1 = '\x5b\x00\x00\x02' '\x04\xba\x48\x39'
+        self.req_bin_1 = b'\x5b\x00\x00\x02' b'\x04\xba\x48\x39'
 
 
     def testPackRequest0(self):
-        bin = apply(request.QueryColors._request.to_binary, (), self.req_args_0)
+        bin = request.QueryColors._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4267,7 +4275,7 @@
             raise AssertionError(args)
 
     def testPackRequest1(self):
-        bin = apply(request.QueryColors._request.to_binary, (), self.req_args_1)
+        bin = request.QueryColors._request.to_binary(*(), **self.req_args_1)
         try:
             assert bin == self.req_bin_1
         except AssertionError:
@@ -4285,7 +4293,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.QueryColors._reply.to_binary, (), self.reply_args_0)
+        bin = request.QueryColors._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4309,9 +4317,9 @@
             'cmap': 789574750,
             'name': 'octarin',
             }
-        self.req_bin_0 = '\x5c\x00\x00\x05' '\x2f\x0f\xf4\x5e' \
-            '\x00\x07\x00\x00' '\x6f\x63\x74\x61' \
-            '\x72\x69\x6e\x00'
+        self.req_bin_0 = b'\x5c\x00\x00\x05' b'\x2f\x0f\xf4\x5e' \
+            b'\x00\x07\x00\x00' b'\x6f\x63\x74\x61' \
+            b'\x72\x69\x6e\x00'
 
         self.reply_args_0 = {
             'sequence_number': 21040,
@@ -4322,14 +4330,14 @@
             'screen_blue': 29893,
             'exact_red': 41875,
             }
-        self.reply_bin_0 = '\x01\x00\x52\x30' '\x00\x00\x00\x00' \
-            '\xa3\x93\xe8\x9a' '\xf0\x48\xc7\x59' \
-            '\xff\x22\x74\xc5' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\x52\x30' b'\x00\x00\x00\x00' \
+            b'\xa3\x93\xe8\x9a' b'\xf0\x48\xc7\x59' \
+            b'\xff\x22\x74\xc5' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.LookupColor._request.to_binary, (), self.req_args_0)
+        bin = request.LookupColor._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4347,7 +4355,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.LookupColor._reply.to_binary, (), self.reply_args_0)
+        bin = request.LookupColor._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4380,14 +4388,14 @@
             'back_red': 31899,
             'source': 794739749,
             }
-        self.req_bin_0 = '\x5d\x00\x00\x08' '\x78\x85\xb3\xb9' \
-            '\x2f\x5e\xc4\x25' '\x19\x0b\x92\xe4' \
-            '\xff\x2b\xa8\x14' '\xf8\x34\x7c\x9b' \
-            '\x13\xe2\xc2\xd7' '\x37\x77\x80\x0c'
+        self.req_bin_0 = b'\x5d\x00\x00\x08' b'\x78\x85\xb3\xb9' \
+            b'\x2f\x5e\xc4\x25' b'\x19\x0b\x92\xe4' \
+            b'\xff\x2b\xa8\x14' b'\xf8\x34\x7c\x9b' \
+            b'\x13\xe2\xc2\xd7' b'\x37\x77\x80\x0c'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CreateCursor._request.to_binary, (), self.req_args_0)
+        bin = request.CreateCursor._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4420,14 +4428,14 @@
             'source': 1412345132,
             'back_green': 52966,
             }
-        self.req_bin_0 = '\x5e\x00\x00\x08' '\x77\x2e\x8e\xfc' \
-            '\x54\x2e\xad\x2c' '\x78\x51\x63\x27' \
-            '\x1d\x90\xb4\x2c' '\xdb\xf2\x42\x5d' \
-            '\x78\x49\xfb\xe4' '\xce\xe6\x19\x64'
+        self.req_bin_0 = b'\x5e\x00\x00\x08' b'\x77\x2e\x8e\xfc' \
+            b'\x54\x2e\xad\x2c' b'\x78\x51\x63\x27' \
+            b'\x1d\x90\xb4\x2c' b'\xdb\xf2\x42\x5d' \
+            b'\x78\x49\xfb\xe4' b'\xce\xe6\x19\x64'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CreateGlyphCursor._request.to_binary, (), self.req_args_0)
+        bin = request.CreateGlyphCursor._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4450,11 +4458,11 @@
         self.req_args_0 = {
             'cursor': 553262138,
             }
-        self.req_bin_0 = '\x5f\x00\x00\x02' '\x20\xfa\x1c\x3a'
+        self.req_bin_0 = b'\x5f\x00\x00\x02' b'\x20\xfa\x1c\x3a'
 
 
     def testPackRequest0(self):
-        bin = apply(request.FreeCursor._request.to_binary, (), self.req_args_0)
+        bin = request.FreeCursor._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4483,13 +4491,13 @@
             'back_red': 64013,
             'cursor': 295995276,
             }
-        self.req_bin_0 = '\x60\x00\x00\x05' '\x11\xa4\x87\x8c' \
-            '\xae\xae\x81\x50' '\x43\x5e\xfa\x0d' \
-            '\x2f\x83\xc1\x7d'
+        self.req_bin_0 = b'\x60\x00\x00\x05' b'\x11\xa4\x87\x8c' \
+            b'\xae\xae\x81\x50' b'\x43\x5e\xfa\x0d' \
+            b'\x2f\x83\xc1\x7d'
 
 
     def testPackRequest0(self):
-        bin = apply(request.RecolorCursor._request.to_binary, (), self.req_args_0)
+        bin = request.RecolorCursor._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4515,22 +4523,22 @@
             'item_class': 1,
             'width': 27916,
             }
-        self.req_bin_0 = '\x61\x01\x00\x03' '\x1e\x02\xc1\x1e' \
-            '\x6d\x0c\x87\xb7'
+        self.req_bin_0 = b'\x61\x01\x00\x03' b'\x1e\x02\xc1\x1e' \
+            b'\x6d\x0c\x87\xb7'
 
         self.reply_args_0 = {
             'height': 60728,
             'sequence_number': 34070,
             'width': 35970,
             }
-        self.reply_bin_0 = '\x01\x00\x85\x16' '\x00\x00\x00\x00' \
-            '\x8c\x82\xed\x38' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\x85\x16' b'\x00\x00\x00\x00' \
+            b'\x8c\x82\xed\x38' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.QueryBestSize._request.to_binary, (), self.req_args_0)
+        bin = request.QueryBestSize._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4548,7 +4556,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.QueryBestSize._reply.to_binary, (), self.reply_args_0)
+        bin = request.QueryBestSize._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4571,8 +4579,8 @@
         self.req_args_0 = {
             'name': 'XTRA',
             }
-        self.req_bin_0 = '\x62\x00\x00\x03' '\x00\x04\x00\x00' \
-            '\x58\x54\x52\x41'
+        self.req_bin_0 = b'\x62\x00\x00\x03' b'\x00\x04\x00\x00' \
+            b'\x58\x54\x52\x41'
 
         self.reply_args_0 = {
             'sequence_number': 39952,
@@ -4581,14 +4589,14 @@
             'present': 1,
             'first_event': 202,
             }
-        self.reply_bin_0 = '\x01\x00\x9c\x10' '\x00\x00\x00\x00' \
-            '\x01\xc3\xca\x96' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\x9c\x10' b'\x00\x00\x00\x00' \
+            b'\x01\xc3\xca\x96' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.QueryExtension._request.to_binary, (), self.req_args_0)
+        bin = request.QueryExtension._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4606,7 +4614,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.QueryExtension._reply.to_binary, (), self.reply_args_0)
+        bin = request.QueryExtension._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4628,22 +4636,22 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x63\x00\x00\x01'
+        self.req_bin_0 = b'\x63\x00\x00\x01'
 
         self.reply_args_0 = {
             'sequence_number': 20200,
             'names': ['XTRA', 'XTRA-II'],
             }
-        self.reply_bin_0 = '\x01\x02\x4e\xe8' '\x00\x00\x00\x04' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x04\x58\x54\x52' '\x41\x07\x58\x54' \
-            '\x52\x41\x2d\x49' '\x49\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x02\x4e\xe8' b'\x00\x00\x00\x04' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x04\x58\x54\x52' b'\x41\x07\x58\x54' \
+            b'\x52\x41\x2d\x49' b'\x49\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ListExtensions._request.to_binary, (), self.req_args_0)
+        bin = request.ListExtensions._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4661,7 +4669,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.ListExtensions._reply.to_binary, (), self.reply_args_0)
+        bin = request.ListExtensions._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4685,41 +4693,41 @@
             'keysyms': [[707837223, 99294840, 1205405602], [67157514, 879853050, 2059131033], [1139736188, 578113249, 1525786315], [1335349176, 246731334, 277761436], [1386594542, 1676932187, 1862777168], [535892916, 342718655, 195574000], [5712156, 1820472637, 848853860], [1123197289, 1664064022, 94999154], [380150420, 402902535, 1061375041], [510686316, 502245882, 422893644], [1423643601, 194077695, 403885178], [1571826296, 529249772, 623556591], [720045879, 37553034, 955963792], [513407882, 861125615, 219940695], [184890179, 472466494, 1649347894], [1679171989, 1991748404, 1674460475], [1762342934, 276695222, 1941684480], [886658026, 1860690072, 577030090], [227169721, 1390318675, 321524615], [2144591365, 545119116, 404205206]],
             'first_keycode': 250,
             }
-        self.req_bin_0 = '\x64\x14\x00\x3e' '\xfa\x03\x00\x00' \
-            '\x2a\x30\xbd\x27' '\x05\xeb\x1e\x78' \
-            '\x47\xd9\x07\xa2' '\x04\x00\xbe\x0a' \
-            '\x34\x71\x7d\xfa' '\x7a\xbb\xd8\x99' \
-            '\x43\xee\xfe\x7c' '\x22\x75\x4e\xe1' \
-            '\x5a\xf1\xa6\xcb' '\x4f\x97\xcf\xb8' \
-            '\x0e\xb4\xd2\x46' '\x10\x8e\x4d\x9c' \
-            '\x52\xa5\xc0\xee' '\x63\xf3\xf4\x5b' \
-            '\x6f\x07\xb9\x50' '\x1f\xf1\x13\xb4' \
-            '\x14\x6d\x78\xbf' '\x0b\xa8\x38\xf0' \
-            '\x00\x57\x29\x1c' '\x6c\x82\x35\x3d' \
-            '\x32\x98\x7b\x64' '\x42\xf2\xa1\x69' \
-            '\x63\x2f\x9a\x16' '\x05\xa9\x92\x72' \
-            '\x16\xa8\xa2\x94' '\x18\x03\xce\x07' \
-            '\x3f\x43\x4c\x41' '\x1e\x70\x74\x6c' \
-            '\x1d\xef\xa9\xfa' '\x19\x34\xd8\x4c' \
-            '\x54\xdb\x13\xd1' '\x0b\x91\x63\xff' \
-            '\x18\x12\xcc\x7a' '\x5d\xb0\x2a\x78' \
-            '\x1f\x8b\xb5\xec' '\x25\x2a\xb7\xef' \
-            '\x2a\xeb\x07\x37' '\x02\x3d\x03\x8a' \
-            '\x38\xfa\xd9\x90' '\x1e\x99\xfb\x8a' \
-            '\x33\x53\xbb\xef' '\x0d\x1c\x07\x57' \
-            '\x0b\x05\x33\x43' '\x1c\x29\x44\x3e' \
-            '\x62\x4f\x0d\x36' '\x64\x16\x21\x95' \
-            '\x76\xb7\xab\x34' '\x63\xce\x3d\x3b' \
-            '\x69\x0b\x38\x16' '\x10\x7e\x08\xb6' \
-            '\x73\xbb\xc1\x00' '\x34\xd9\x53\xea' \
-            '\x6e\xe7\xe0\x98' '\x22\x64\xc7\xca' \
-            '\x0d\x8a\x55\xb9' '\x52\xde\x94\x53' \
-            '\x13\x2a\x13\x87' '\x7f\xd3\xde\x05' \
-            '\x20\x7d\xdb\x8c' '\x18\x17\xae\x96'
+        self.req_bin_0 = b'\x64\x14\x00\x3e' b'\xfa\x03\x00\x00' \
+            b'\x2a\x30\xbd\x27' b'\x05\xeb\x1e\x78' \
+            b'\x47\xd9\x07\xa2' b'\x04\x00\xbe\x0a' \
+            b'\x34\x71\x7d\xfa' b'\x7a\xbb\xd8\x99' \
+            b'\x43\xee\xfe\x7c' b'\x22\x75\x4e\xe1' \
+            b'\x5a\xf1\xa6\xcb' b'\x4f\x97\xcf\xb8' \
+            b'\x0e\xb4\xd2\x46' b'\x10\x8e\x4d\x9c' \
+            b'\x52\xa5\xc0\xee' b'\x63\xf3\xf4\x5b' \
+            b'\x6f\x07\xb9\x50' b'\x1f\xf1\x13\xb4' \
+            b'\x14\x6d\x78\xbf' b'\x0b\xa8\x38\xf0' \
+            b'\x00\x57\x29\x1c' b'\x6c\x82\x35\x3d' \
+            b'\x32\x98\x7b\x64' b'\x42\xf2\xa1\x69' \
+            b'\x63\x2f\x9a\x16' b'\x05\xa9\x92\x72' \
+            b'\x16\xa8\xa2\x94' b'\x18\x03\xce\x07' \
+            b'\x3f\x43\x4c\x41' b'\x1e\x70\x74\x6c' \
+            b'\x1d\xef\xa9\xfa' b'\x19\x34\xd8\x4c' \
+            b'\x54\xdb\x13\xd1' b'\x0b\x91\x63\xff' \
+            b'\x18\x12\xcc\x7a' b'\x5d\xb0\x2a\x78' \
+            b'\x1f\x8b\xb5\xec' b'\x25\x2a\xb7\xef' \
+            b'\x2a\xeb\x07\x37' b'\x02\x3d\x03\x8a' \
+            b'\x38\xfa\xd9\x90' b'\x1e\x99\xfb\x8a' \
+            b'\x33\x53\xbb\xef' b'\x0d\x1c\x07\x57' \
+            b'\x0b\x05\x33\x43' b'\x1c\x29\x44\x3e' \
+            b'\x62\x4f\x0d\x36' b'\x64\x16\x21\x95' \
+            b'\x76\xb7\xab\x34' b'\x63\xce\x3d\x3b' \
+            b'\x69\x0b\x38\x16' b'\x10\x7e\x08\xb6' \
+            b'\x73\xbb\xc1\x00' b'\x34\xd9\x53\xea' \
+            b'\x6e\xe7\xe0\x98' b'\x22\x64\xc7\xca' \
+            b'\x0d\x8a\x55\xb9' b'\x52\xde\x94\x53' \
+            b'\x13\x2a\x13\x87' b'\x7f\xd3\xde\x05' \
+            b'\x20\x7d\xdb\x8c' b'\x18\x17\xae\x96'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangeKeyboardMapping._request.to_binary, (), self.req_args_0)
+        bin = request.ChangeKeyboardMapping._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4743,50 +4751,50 @@
             'count': 131,
             'first_keycode': 206,
             }
-        self.req_bin_0 = '\x65\x00\x00\x02' '\xce\x83\x00\x00'
+        self.req_bin_0 = b'\x65\x00\x00\x02' b'\xce\x83\x00\x00'
 
         self.reply_args_0 = {
             'keysyms': [[1550369014, 1683205347, 1879538861], [452613596, 1132022246, 357271408], [528724632, 2118423140, 640580111], [1981239140, 195173082, 497130901], [2001675011, 809172000, 1577756130], [739794769, 1774524806, 787951551], [1784021539, 1998872082, 1747812414], [396316053, 1525431160, 1808906812], [1676662850, 1222579650, 1205117622], [396026453, 1956747483, 1762026309], [1222502216, 1488139702, 1799119214], [1504675136, 1414564657, 419659384], [1934768917, 2095924224, 590955729], [582168798, 383228141, 1552516537], [1482483262, 1041896520, 1047041873], [1932705867, 292473490, 226147737], [780322016, 1965031752, 1481062205], [89811542, 1313413666, 686267194], [237776128, 1310737228, 792176733], [849034415, 1592538831, 837355505]],
             'sequence_number': 61409,
             }
-        self.reply_bin_0 = '\x01\x03\xef\xe1' '\x00\x00\x00\x3c' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x5c\x68\xc0\xf6' '\x64\x53\xac\xe3' \
-            '\x70\x07\x7c\xad' '\x1a\xfa\x55\xdc' \
-            '\x43\x79\x49\xe6' '\x15\x4b\x87\x70' \
-            '\x1f\x83\xb2\x98' '\x7e\x44\x92\x64' \
-            '\x26\x2e\x7a\x0f' '\x76\x17\x4f\x64' \
-            '\x0b\xa2\x1a\xda' '\x1d\xa1\x9d\x95' \
-            '\x77\x4f\x23\x03' '\x30\x3a\xfc\x20' \
-            '\x5e\x0a\xa5\xe2' '\x2c\x18\x5f\x51' \
-            '\x69\xc5\x19\x86' '\x2e\xf7\x2f\xbf' \
-            '\x6a\x56\x02\x23' '\x77\x24\x5e\x12' \
-            '\x68\x2d\x80\x3e' '\x17\x9f\x4d\x95' \
-            '\x5a\xec\x3b\x78' '\x6b\xd1\xba\x3c' \
-            '\x63\xef\xd8\x42' '\x48\xdf\x15\xc2' \
-            '\x47\xd4\xa2\xb6' '\x17\x9a\xe2\x55' \
-            '\x74\xa1\x98\xdb' '\x69\x06\x63\x45' \
-            '\x48\xdd\xe7\x48' '\x58\xb3\x35\xb6' \
-            '\x6b\x3c\x61\x6e' '\x59\xaf\x85\x40' \
-            '\x54\x50\x8b\x31' '\x19\x03\x7e\x78' \
-            '\x73\x52\x3b\x15' '\x7c\xed\x44\x00' \
-            '\x23\x39\x44\xd1' '\x22\xb3\x30\xde' \
-            '\x16\xd7\x98\xed' '\x5c\x89\x85\xb9' \
-            '\x58\x5c\xe6\x3e' '\x3e\x1a\x14\x48' \
-            '\x3e\x68\x97\x51' '\x73\x32\xc0\x4b' \
-            '\x11\x6e\xca\x92' '\x0d\x7a\xbd\x99' \
-            '\x2e\x82\xc4\xe0' '\x75\x20\x01\x48' \
-            '\x58\x47\x37\x3d' '\x05\x5a\x6a\x56' \
-            '\x4e\x49\x1a\x22' '\x28\xe7\x9b\x3a' \
-            '\x0e\x2c\x2d\x00' '\x4e\x20\x43\x4c' \
-            '\x2f\x37\xa8\x5d' '\x32\x9b\x3c\xaf' \
-            '\x5e\xec\x36\xcf' '\x31\xe9\x07\xf1'
+        self.reply_bin_0 = b'\x01\x03\xef\xe1' b'\x00\x00\x00\x3c' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x5c\x68\xc0\xf6' b'\x64\x53\xac\xe3' \
+            b'\x70\x07\x7c\xad' b'\x1a\xfa\x55\xdc' \
+            b'\x43\x79\x49\xe6' b'\x15\x4b\x87\x70' \
+            b'\x1f\x83\xb2\x98' b'\x7e\x44\x92\x64' \
+            b'\x26\x2e\x7a\x0f' b'\x76\x17\x4f\x64' \
+            b'\x0b\xa2\x1a\xda' b'\x1d\xa1\x9d\x95' \
+            b'\x77\x4f\x23\x03' b'\x30\x3a\xfc\x20' \
+            b'\x5e\x0a\xa5\xe2' b'\x2c\x18\x5f\x51' \
+            b'\x69\xc5\x19\x86' b'\x2e\xf7\x2f\xbf' \
+            b'\x6a\x56\x02\x23' b'\x77\x24\x5e\x12' \
+            b'\x68\x2d\x80\x3e' b'\x17\x9f\x4d\x95' \
+            b'\x5a\xec\x3b\x78' b'\x6b\xd1\xba\x3c' \
+            b'\x63\xef\xd8\x42' b'\x48\xdf\x15\xc2' \
+            b'\x47\xd4\xa2\xb6' b'\x17\x9a\xe2\x55' \
+            b'\x74\xa1\x98\xdb' b'\x69\x06\x63\x45' \
+            b'\x48\xdd\xe7\x48' b'\x58\xb3\x35\xb6' \
+            b'\x6b\x3c\x61\x6e' b'\x59\xaf\x85\x40' \
+            b'\x54\x50\x8b\x31' b'\x19\x03\x7e\x78' \
+            b'\x73\x52\x3b\x15' b'\x7c\xed\x44\x00' \
+            b'\x23\x39\x44\xd1' b'\x22\xb3\x30\xde' \
+            b'\x16\xd7\x98\xed' b'\x5c\x89\x85\xb9' \
+            b'\x58\x5c\xe6\x3e' b'\x3e\x1a\x14\x48' \
+            b'\x3e\x68\x97\x51' b'\x73\x32\xc0\x4b' \
+            b'\x11\x6e\xca\x92' b'\x0d\x7a\xbd\x99' \
+            b'\x2e\x82\xc4\xe0' b'\x75\x20\x01\x48' \
+            b'\x58\x47\x37\x3d' b'\x05\x5a\x6a\x56' \
+            b'\x4e\x49\x1a\x22' b'\x28\xe7\x9b\x3a' \
+            b'\x0e\x2c\x2d\x00' b'\x4e\x20\x43\x4c' \
+            b'\x2f\x37\xa8\x5d' b'\x32\x9b\x3c\xaf' \
+            b'\x5e\xec\x36\xcf' b'\x31\xe9\x07\xf1'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetKeyboardMapping._request.to_binary, (), self.req_args_0)
+        bin = request.GetKeyboardMapping._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4804,7 +4812,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetKeyboardMapping._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetKeyboardMapping._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4827,15 +4835,15 @@
         self.req_args_0 = {
             'attrs': {'key_click_percent': -35, 'bell_percent': -53, 'led_mode': 1, 'bell_pitch': -17390, 'auto_repeat_mode': 2, 'bell_duration': -30281, 'key': 235, 'led': 192},
             }
-        self.req_bin_0 = '\x66\x00\x00\x0a' '\x00\x00\x00\xff' \
-            '\xdd\x00\x00\x00' '\xcb\x00\x00\x00' \
-            '\xbc\x12\x00\x00' '\x89\xb7\x00\x00' \
-            '\xc0\x00\x00\x00' '\x01\x00\x00\x00' \
-            '\xeb\x00\x00\x00' '\x02\x00\x00\x00'
+        self.req_bin_0 = b'\x66\x00\x00\x0a' b'\x00\x00\x00\xff' \
+            b'\xdd\x00\x00\x00' b'\xcb\x00\x00\x00' \
+            b'\xbc\x12\x00\x00' b'\x89\xb7\x00\x00' \
+            b'\xc0\x00\x00\x00' b'\x01\x00\x00\x00' \
+            b'\xeb\x00\x00\x00' b'\x02\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangeKeyboardControl._request.to_binary, (), self.req_args_0)
+        bin = request.ChangeKeyboardControl._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4857,7 +4865,7 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x67\x00\x00\x01'
+        self.req_bin_0 = b'\x67\x00\x00\x01'
 
         self.reply_args_0 = {
             'key_click_percent': 206,
@@ -4869,17 +4877,17 @@
             'led_mask': 438224369,
             'bell_duration': 20235,
             }
-        self.reply_bin_0 = '\x01\x00\x75\xc5' '\x00\x00\x00\x05' \
-            '\x1a\x1e\xc5\xf1' '\xce\xfb\x35\xd3' \
-            '\x4f\x0b\x00\x00' '\xd9\xab\xa7\xa7' \
-            '\xf3\xa3\x81\xef' '\xa8\x99\xe1\xc7' \
-            '\xbd\x9b\xe4\x95' '\x94\xed\x8b\x96' \
-            '\xd3\x85\x87\xfa' '\xbf\xa6\x92\xd4' \
-            '\xef\xb7\xd6\xfa'
+        self.reply_bin_0 = b'\x01\x00\x75\xc5' b'\x00\x00\x00\x05' \
+            b'\x1a\x1e\xc5\xf1' b'\xce\xfb\x35\xd3' \
+            b'\x4f\x0b\x00\x00' b'\xd9\xab\xa7\xa7' \
+            b'\xf3\xa3\x81\xef' b'\xa8\x99\xe1\xc7' \
+            b'\xbd\x9b\xe4\x95' b'\x94\xed\x8b\x96' \
+            b'\xd3\x85\x87\xfa' b'\xbf\xa6\x92\xd4' \
+            b'\xef\xb7\xd6\xfa'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetKeyboardControl._request.to_binary, (), self.req_args_0)
+        bin = request.GetKeyboardControl._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4897,7 +4905,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetKeyboardControl._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetKeyboardControl._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4920,11 +4928,11 @@
         self.req_args_0 = {
             'percent': -19,
             }
-        self.req_bin_0 = '\x68\xed\x00\x01'
+        self.req_bin_0 = b'\x68\xed\x00\x01'
 
 
     def testPackRequest0(self):
-        bin = apply(request.Bell._request.to_binary, (), self.req_args_0)
+        bin = request.Bell._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4951,12 +4959,12 @@
             'do_thresh': 0,
             'threshold': -8309,
             }
-        self.req_bin_0 = '\x69\x00\x00\x03' '\xdb\x7e\x81\x1c' \
-            '\xdf\x8b\x00\x00'
+        self.req_bin_0 = b'\x69\x00\x00\x03' b'\xdb\x7e\x81\x1c' \
+            b'\xdf\x8b\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangePointerControl._request.to_binary, (), self.req_args_0)
+        bin = request.ChangePointerControl._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4978,7 +4986,7 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x6a\x00\x00\x01'
+        self.req_bin_0 = b'\x6a\x00\x00\x01'
 
         self.reply_args_0 = {
             'accel_denom': 63793,
@@ -4986,14 +4994,14 @@
             'threshold': 46060,
             'accel_num': 53419,
             }
-        self.reply_bin_0 = '\x01\x00\xea\x2a' '\x00\x00\x00\x00' \
-            '\xd0\xab\xf9\x31' '\xb3\xec\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\xea\x2a' b'\x00\x00\x00\x00' \
+            b'\xd0\xab\xf9\x31' b'\xb3\xec\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetPointerControl._request.to_binary, (), self.req_args_0)
+        bin = request.GetPointerControl._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5011,7 +5019,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetPointerControl._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetPointerControl._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -5037,12 +5045,12 @@
             'interval': -12318,
             'prefer_blank': 2,
             }
-        self.req_bin_0 = '\x6b\x00\x00\x03' '\xce\x7d\xcf\xe2' \
-            '\x02\x00\x00\x00'
+        self.req_bin_0 = b'\x6b\x00\x00\x03' b'\xce\x7d\xcf\xe2' \
+            b'\x02\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetScreenSaver._request.to_binary, (), self.req_args_0)
+        bin = request.SetScreenSaver._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5064,7 +5072,7 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x6c\x00\x00\x01'
+        self.req_bin_0 = b'\x6c\x00\x00\x01'
 
         self.reply_args_0 = {
             'allow_exposures': 1,
@@ -5073,14 +5081,14 @@
             'prefer_blanking': 1,
             'interval': 60559,
             }
-        self.reply_bin_0 = '\x01\x00\x39\x52' '\x00\x00\x00\x00' \
-            '\x07\x49\xec\x8f' '\x01\x01\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\x39\x52' b'\x00\x00\x00\x00' \
+            b'\x07\x49\xec\x8f' b'\x01\x01\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetScreenSaver._request.to_binary, (), self.req_args_0)
+        bin = request.GetScreenSaver._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5098,7 +5106,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetScreenSaver._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetScreenSaver._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -5123,12 +5131,12 @@
             'mode': 1,
             'host_family': 1,
             }
-        self.req_bin_0 = '\x6d\x01\x00\x03' '\x01\x00\x00\x04' \
-            '\xbc\xe2\x87\xc7'
+        self.req_bin_0 = b'\x6d\x01\x00\x03' b'\x01\x00\x00\x04' \
+            b'\xbc\xe2\x87\xc7'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangeHosts._request.to_binary, (), self.req_args_0)
+        bin = request.ChangeHosts._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5150,23 +5158,23 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x6e\x00\x00\x01'
+        self.req_bin_0 = b'\x6e\x00\x00\x01'
 
         self.reply_args_0 = {
             'sequence_number': 31662,
             'mode': 1,
             'hosts': [{'family': 0, 'name': [34, 23, 178, 12]}, {'family': 0, 'name': [130, 236, 254, 15]}],
             }
-        self.reply_bin_0 = '\x01\x01\x7b\xae' '\x00\x00\x00\x04' \
-            '\x00\x02\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x04' '\x22\x17\xb2\x0c' \
-            '\x00\x00\x00\x04' '\x82\xec\xfe\x0f'
+        self.reply_bin_0 = b'\x01\x01\x7b\xae' b'\x00\x00\x00\x04' \
+            b'\x00\x02\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x04' b'\x22\x17\xb2\x0c' \
+            b'\x00\x00\x00\x04' b'\x82\xec\xfe\x0f'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ListHosts._request.to_binary, (), self.req_args_0)
+        bin = request.ListHosts._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5184,7 +5192,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.ListHosts._reply.to_binary, (), self.reply_args_0)
+        bin = request.ListHosts._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -5207,11 +5215,11 @@
         self.req_args_0 = {
             'mode': 0,
             }
-        self.req_bin_0 = '\x6f\x00\x00\x01'
+        self.req_bin_0 = b'\x6f\x00\x00\x01'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetAccessControl._request.to_binary, (), self.req_args_0)
+        bin = request.SetAccessControl._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5234,11 +5242,11 @@
         self.req_args_0 = {
             'mode': 0,
             }
-        self.req_bin_0 = '\x70\x00\x00\x01'
+        self.req_bin_0 = b'\x70\x00\x00\x01'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetCloseDownMode._request.to_binary, (), self.req_args_0)
+        bin = request.SetCloseDownMode._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5261,11 +5269,11 @@
         self.req_args_0 = {
             'resource': 1679944210,
             }
-        self.req_bin_0 = '\x71\x00\x00\x02' '\x64\x21\xea\x12'
+        self.req_bin_0 = b'\x71\x00\x00\x02' b'\x64\x21\xea\x12'
 
 
     def testPackRequest0(self):
-        bin = apply(request.KillClient._request.to_binary, (), self.req_args_0)
+        bin = request.KillClient._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5290,18 +5298,18 @@
             'window': 109899869,
             'properties': [1758270592, 1474783027, 1362037883, 19212066, 1095428186, 1435857629, 337040311, 1202859364, 1426187239, 725785004, 1722986690, 435243112],
             }
-        self.req_bin_0 = '\x72\x00\x00\x0f' '\x06\x8c\xf0\x5d' \
-            '\x00\x0c\x96\x29' '\x68\xcd\x14\x80' \
-            '\x57\xe7\x67\x33' '\x51\x2f\x0c\x7b' \
-            '\x01\x25\x27\x22' '\x41\x4a\xe8\x5a' \
-            '\x55\x95\x72\xdd' '\x14\x16\xd3\xb7' \
-            '\x47\xb2\x2d\x64' '\x55\x01\xe3\xe7' \
-            '\x2b\x42\x99\xac' '\x66\xb2\xb0\xc2' \
-            '\x19\xf1\x48\x68'
+        self.req_bin_0 = b'\x72\x00\x00\x0f' b'\x06\x8c\xf0\x5d' \
+            b'\x00\x0c\x96\x29' b'\x68\xcd\x14\x80' \
+            b'\x57\xe7\x67\x33' b'\x51\x2f\x0c\x7b' \
+            b'\x01\x25\x27\x22' b'\x41\x4a\xe8\x5a' \
+            b'\x55\x95\x72\xdd' b'\x14\x16\xd3\xb7' \
+            b'\x47\xb2\x2d\x64' b'\x55\x01\xe3\xe7' \
+            b'\x2b\x42\x99\xac' b'\x66\xb2\xb0\xc2' \
+            b'\x19\xf1\x48\x68'
 
 
     def testPackRequest0(self):
-        bin = apply(request.RotateProperties._request.to_binary, (), self.req_args_0)
+        bin = request.RotateProperties._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5324,11 +5332,11 @@
         self.req_args_0 = {
             'mode': 1,
             }
-        self.req_bin_0 = '\x73\x01\x00\x01'
+        self.req_bin_0 = b'\x73\x01\x00\x01'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ForceScreenSaver._request.to_binary, (), self.req_args_0)
+        bin = request.ForceScreenSaver._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5351,21 +5359,21 @@
         self.req_args_0 = {
             'map': [218, 142, 195, 250, 194],
             }
-        self.req_bin_0 = '\x74\x05\x00\x03' '\xda\x8e\xc3\xfa' \
-            '\xc2\x00\x00\x00'
+        self.req_bin_0 = b'\x74\x05\x00\x03' b'\xda\x8e\xc3\xfa' \
+            b'\xc2\x00\x00\x00'
 
         self.reply_args_0 = {
             'sequence_number': 11995,
             'status': 187,
             }
-        self.reply_bin_0 = '\x01\xbb\x2e\xdb' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\xbb\x2e\xdb' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetPointerMapping._request.to_binary, (), self.req_args_0)
+        bin = request.SetPointerMapping._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5383,7 +5391,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.SetPointerMapping._reply.to_binary, (), self.reply_args_0)
+        bin = request.SetPointerMapping._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -5405,21 +5413,21 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x75\x00\x00\x01'
+        self.req_bin_0 = b'\x75\x00\x00\x01'
 
         self.reply_args_0 = {
             'sequence_number': 35825,
             'map': [165, 233, 136, 197, 230],
             }
-        self.reply_bin_0 = '\x01\x05\x8b\xf1' '\x00\x00\x00\x02' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\xa5\xe9\x88\xc5' '\xe6\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x05\x8b\xf1' b'\x00\x00\x00\x02' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\xa5\xe9\x88\xc5' b'\xe6\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetPointerMapping._request.to_binary, (), self.req_args_0)
+        bin = request.GetPointerMapping._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5437,7 +5445,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetPointerMapping._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetPointerMapping._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -5460,22 +5468,22 @@
         self.req_args_0 = {
             'keycodes': [[72, 169], [161, 154], [26, 10], [108, 187], [110, 198], [225, 88], [33, 66], [189, 147]],
             }
-        self.req_bin_0 = '\x76\x02\x00\x05' '\x48\xa9\xa1\x9a' \
-            '\x1a\x0a\x6c\xbb' '\x6e\xc6\xe1\x58' \
-            '\x21\x42\xbd\x93'
+        self.req_bin_0 = b'\x76\x02\x00\x05' b'\x48\xa9\xa1\x9a' \
+            b'\x1a\x0a\x6c\xbb' b'\x6e\xc6\xe1\x58' \
+            b'\x21\x42\xbd\x93'
 
         self.reply_args_0 = {
             'sequence_number': 44526,
             'status': 188,
             }
-        self.reply_bin_0 = '\x01\xbc\xad\xee' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\xbc\xad\xee' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetModifierMapping._request.to_binary, (), self.req_args_0)
+        bin = request.SetModifierMapping._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5493,7 +5501,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.SetModifierMapping._reply.to_binary, (), self.reply_args_0)
+        bin = request.SetModifierMapping._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -5515,22 +5523,22 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x77\x00\x00\x01'
+        self.req_bin_0 = b'\x77\x00\x00\x01'
 
         self.reply_args_0 = {
             'sequence_number': 58377,
             'keycodes': [[3, 183], [213, 173], [9, 97], [35, 60], [249, 78], [175, 62], [237, 11], [26, 119]],
             }
-        self.reply_bin_0 = '\x01\x02\xe4\x09' '\x00\x00\x00\x04' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x03\xb7\xd5\xad' '\x09\x61\x23\x3c' \
-            '\xf9\x4e\xaf\x3e' '\xed\x0b\x1a\x77'
+        self.reply_bin_0 = b'\x01\x02\xe4\x09' b'\x00\x00\x00\x04' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x03\xb7\xd5\xad' b'\x09\x61\x23\x3c' \
+            b'\xf9\x4e\xaf\x3e' b'\xed\x0b\x1a\x77'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetModifierMapping._request.to_binary, (), self.req_args_0)
+        bin = request.GetModifierMapping._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5548,7 +5556,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetModifierMapping._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetModifierMapping._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -5570,11 +5578,11 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x7f\x00\x00\x01'
+        self.req_bin_0 = b'\x7f\x00\x00\x01'
 
 
     def testPackRequest0(self):
-        bin = apply(request.NoOperation._request.to_binary, (), self.req_args_0)
+        bin = request.NoOperation._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
Index: python-xlib-0.14+20091101/test/test_requests_le.py
===================================================================
--- python-xlib-0.14+20091101.orig/test/test_requests_le.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/test/test_requests_le.py	2013-10-11 14:19:21.113971349 -0400
@@ -3,7 +3,6 @@
 import sys, os
 sys.path.insert(1, os.path.join(sys.path[0], '..'))
 
-import string
 import unittest
 from Xlib.protocol import request, rq, event
 import Xlib.protocol.event
@@ -13,7 +12,7 @@
 
 class CmpArray:
     def __init__(self, *args, **kws):
-        self.array = apply(array.array, args, kws)
+        self.array = array.array(*args, **kws)
 
     def __len__(self):
         return len(self.array)
@@ -21,16 +20,25 @@
     def __getslice__(self, x, y):
         return list(self.array[x:y])
 
+    def __getitem__(self, n):
+        if isinstance(n, slice):
+            return list(self.array.__getitem__(n))
+        else:
+            return self.array[n]
+
     def __getattr__(self, attr):
         return getattr(self.array, attr)
 
-    def __cmp__(self, other):
-        return cmp(self.array.tolist(), other)
+    def __eq__(self, other):
+        return self.array.tolist() == other
+
+    def __ne__(self, other):
+        return self.array.tolist() != other
 
 rq.array = CmpArray
 
 def tohex(bin):
-    bin = string.join(map(lambda c: '\\x%02x' % ord(c), bin), '')
+    bin = ''.join(map(lambda c: '\\x%02x' % c, bin))
 
     bins = []
     for i in range(0, len(bin), 16):
@@ -43,7 +51,7 @@
         except IndexError:
             bins2.append("'%s'" % bins[i])
 
-    return string.join(bins2, ' \\\n            ')
+    return ' \\\n            '.join(bins2)
 
 class DummyDisplay:
     def get_resource_class(self, x):
@@ -75,22 +83,22 @@
             'border_width': 29625,
             'window_class': 2,
             }
-        self.req_bin_0 = '\x01\xc6\x17\x00' '\xa1\x2e\xb9\x25' \
-            '\x30\xfa\x8f\x21' '\x42\xe9\x11\x8d' \
-            '\x1f\xd7\x5b\xf2' '\xb9\x73\x02\x00' \
-            '\x4d\x3e\x64\x30' '\xff\x7f\x00\x00' \
-            '\x58\x2e\x54\x4e' '\x2c\x67\x7e\x2a' \
-            '\x35\x39\xa1\x1e' '\x2c\x60\x60\x51' \
-            '\x06\x00\x00\x00' '\x06\x00\x00\x00' \
-            '\x01\x00\x00\x00' '\xc4\x0f\xc8\x34' \
-            '\x1e\xac\xf5\x64' '\x01\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x33\x4a\x4c\x35' \
-            '\xc3\x5e\xcd\x27' '\xb9\xb0\x69\x3a' \
-            '\x28\x59\xfa\x2e'
+        self.req_bin_0 = b'\x01\xc6\x17\x00' b'\xa1\x2e\xb9\x25' \
+            b'\x30\xfa\x8f\x21' b'\x42\xe9\x11\x8d' \
+            b'\x1f\xd7\x5b\xf2' b'\xb9\x73\x02\x00' \
+            b'\x4d\x3e\x64\x30' b'\xff\x7f\x00\x00' \
+            b'\x58\x2e\x54\x4e' b'\x2c\x67\x7e\x2a' \
+            b'\x35\x39\xa1\x1e' b'\x2c\x60\x60\x51' \
+            b'\x06\x00\x00\x00' b'\x06\x00\x00\x00' \
+            b'\x01\x00\x00\x00' b'\xc4\x0f\xc8\x34' \
+            b'\x1e\xac\xf5\x64' b'\x01\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x33\x4a\x4c\x35' \
+            b'\xc3\x5e\xcd\x27' b'\xb9\xb0\x69\x3a' \
+            b'\x28\x59\xfa\x2e'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CreateWindow._request.to_binary, (), self.req_args_0)
+        bin = request.CreateWindow._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -114,19 +122,19 @@
             'window': 560274578,
             'attrs': {'cursor': 1238338372, 'override_redirect': 0, 'bit_gravity': 6, 'event_mask': 1980992429, 'border_pixel': 310964771, 'background_pixel': 1268171782, 'save_under': 1, 'colormap': 171538239, 'do_not_propagate_mask': 135558419, 'backing_store': 2, 'win_gravity': 10, 'backing_planes': 252687930, 'border_pixmap': 287169917, 'backing_pixel': 1114685309, 'background_pixmap': 2004887498},
             }
-        self.req_bin_0 = '\x02\x00\x12\x00' '\x92\x1c\x65\x21' \
-            '\xff\x7f\x00\x00' '\xca\x27\x80\x77' \
-            '\x06\xc4\x96\x4b' '\x7d\xdd\x1d\x11' \
-            '\x23\xf2\x88\x12' '\x06\x00\x00\x00' \
-            '\x0a\x00\x00\x00' '\x02\x00\x00\x00' \
-            '\x3a\xb6\x0f\x0f' '\x7d\xbf\x70\x42' \
-            '\x00\x00\x00\x00' '\x01\x00\x00\x00' \
-            '\xad\x8b\x13\x76' '\x13\x75\x14\x08' \
-            '\x3f\x77\x39\x0a' '\x44\x8b\xcf\x49'
+        self.req_bin_0 = b'\x02\x00\x12\x00' b'\x92\x1c\x65\x21' \
+            b'\xff\x7f\x00\x00' b'\xca\x27\x80\x77' \
+            b'\x06\xc4\x96\x4b' b'\x7d\xdd\x1d\x11' \
+            b'\x23\xf2\x88\x12' b'\x06\x00\x00\x00' \
+            b'\x0a\x00\x00\x00' b'\x02\x00\x00\x00' \
+            b'\x3a\xb6\x0f\x0f' b'\x7d\xbf\x70\x42' \
+            b'\x00\x00\x00\x00' b'\x01\x00\x00\x00' \
+            b'\xad\x8b\x13\x76' b'\x13\x75\x14\x08' \
+            b'\x3f\x77\x39\x0a' b'\x44\x8b\xcf\x49'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangeWindowAttributes._request.to_binary, (), self.req_args_0)
+        bin = request.ChangeWindowAttributes._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -149,7 +157,7 @@
         self.req_args_0 = {
             'window': 1672572666,
             }
-        self.req_bin_0 = '\x03\x00\x02\x00' '\xfa\x6e\xb1\x63'
+        self.req_bin_0 = b'\x03\x00\x02\x00' b'\xfa\x6e\xb1\x63'
 
         self.reply_args_0 = {
             'do_not_propagate_mask': 33915,
@@ -169,16 +177,16 @@
             'sequence_number': 38504,
             'colormap': 56062036,
             }
-        self.reply_bin_0 = '\x01\xd7\x68\x96' '\x03\x00\x00\x00' \
-            '\xb5\x61\x9f\x54' '\x28\x3f\x80\x8c' \
-            '\xce\xd7\xa2\x32' '\x99\xf4\xa7\x37' \
-            '\x01\x01\xa9\x00' '\x54\x70\x57\x03' \
-            '\xb4\x01\xc9\x3d' '\x52\xc6\x49\x0a' \
-            '\x7b\x84\x00\x00'
+        self.reply_bin_0 = b'\x01\xd7\x68\x96' b'\x03\x00\x00\x00' \
+            b'\xb5\x61\x9f\x54' b'\x28\x3f\x80\x8c' \
+            b'\xce\xd7\xa2\x32' b'\x99\xf4\xa7\x37' \
+            b'\x01\x01\xa9\x00' b'\x54\x70\x57\x03' \
+            b'\xb4\x01\xc9\x3d' b'\x52\xc6\x49\x0a' \
+            b'\x7b\x84\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetWindowAttributes._request.to_binary, (), self.req_args_0)
+        bin = request.GetWindowAttributes._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -196,7 +204,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetWindowAttributes._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetWindowAttributes._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -219,11 +227,11 @@
         self.req_args_0 = {
             'window': 533632985,
             }
-        self.req_bin_0 = '\x04\x00\x02\x00' '\xd9\x97\xce\x1f'
+        self.req_bin_0 = b'\x04\x00\x02\x00' b'\xd9\x97\xce\x1f'
 
 
     def testPackRequest0(self):
-        bin = apply(request.DestroyWindow._request.to_binary, (), self.req_args_0)
+        bin = request.DestroyWindow._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -246,11 +254,11 @@
         self.req_args_0 = {
             'window': 490680451,
             }
-        self.req_bin_0 = '\x05\x00\x02\x00' '\x83\x30\x3f\x1d'
+        self.req_bin_0 = b'\x05\x00\x02\x00' b'\x83\x30\x3f\x1d'
 
 
     def testPackRequest0(self):
-        bin = apply(request.DestroySubWindows._request.to_binary, (), self.req_args_0)
+        bin = request.DestroySubWindows._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -274,11 +282,11 @@
             'window': 1974200014,
             'mode': 0,
             }
-        self.req_bin_0 = '\x06\x00\x02\x00' '\xce\xe6\xab\x75'
+        self.req_bin_0 = b'\x06\x00\x02\x00' b'\xce\xe6\xab\x75'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangeSaveSet._request.to_binary, (), self.req_args_0)
+        bin = request.ChangeSaveSet._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -304,12 +312,12 @@
             'window': 2127670410,
             'parent': 1913134105,
             }
-        self.req_bin_0 = '\x07\x00\x04\x00' '\x8a\xac\xd1\x7e' \
-            '\x19\x1c\x08\x72' '\x10\xb9\x25\xce'
+        self.req_bin_0 = b'\x07\x00\x04\x00' b'\x8a\xac\xd1\x7e' \
+            b'\x19\x1c\x08\x72' b'\x10\xb9\x25\xce'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ReparentWindow._request.to_binary, (), self.req_args_0)
+        bin = request.ReparentWindow._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -332,11 +340,11 @@
         self.req_args_0 = {
             'window': 962670079,
             }
-        self.req_bin_0 = '\x08\x00\x02\x00' '\xff\x2d\x61\x39'
+        self.req_bin_0 = b'\x08\x00\x02\x00' b'\xff\x2d\x61\x39'
 
 
     def testPackRequest0(self):
-        bin = apply(request.MapWindow._request.to_binary, (), self.req_args_0)
+        bin = request.MapWindow._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -359,11 +367,11 @@
         self.req_args_0 = {
             'window': 447820952,
             }
-        self.req_bin_0 = '\x09\x00\x02\x00' '\x98\x34\xb1\x1a'
+        self.req_bin_0 = b'\x09\x00\x02\x00' b'\x98\x34\xb1\x1a'
 
 
     def testPackRequest0(self):
-        bin = apply(request.MapSubwindows._request.to_binary, (), self.req_args_0)
+        bin = request.MapSubwindows._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -386,11 +394,11 @@
         self.req_args_0 = {
             'window': 1130502889,
             }
-        self.req_bin_0 = '\x0a\x00\x02\x00' '\xe9\x1a\x62\x43'
+        self.req_bin_0 = b'\x0a\x00\x02\x00' b'\xe9\x1a\x62\x43'
 
 
     def testPackRequest0(self):
-        bin = apply(request.UnmapWindow._request.to_binary, (), self.req_args_0)
+        bin = request.UnmapWindow._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -413,11 +421,11 @@
         self.req_args_0 = {
             'window': 2009442907,
             }
-        self.req_bin_0 = '\x0b\x00\x02\x00' '\x5b\xaa\xc5\x77'
+        self.req_bin_0 = b'\x0b\x00\x02\x00' b'\x5b\xaa\xc5\x77'
 
 
     def testPackRequest0(self):
-        bin = apply(request.UnmapSubwindows._request.to_binary, (), self.req_args_0)
+        bin = request.UnmapSubwindows._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -441,15 +449,15 @@
             'window': 2092974410,
             'attrs': {'sibling': 1102940930, 'width': 52077, 'y': -11332, 'x': -11514, 'border_width': -6900, 'stack_mode': 4, 'height': 62050},
             }
-        self.req_bin_0 = '\x0c\x00\x0a\x00' '\x4a\x41\xc0\x7c' \
-            '\x7f\x00\x00\x00' '\x06\xd3\x00\x00' \
-            '\xbc\xd3\x00\x00' '\x6d\xcb\x00\x00' \
-            '\x62\xf2\x00\x00' '\x0c\xe5\x00\x00' \
-            '\x02\x8b\xbd\x41' '\x04\x00\x00\x00'
+        self.req_bin_0 = b'\x0c\x00\x0a\x00' b'\x4a\x41\xc0\x7c' \
+            b'\x7f\x00\x00\x00' b'\x06\xd3\x00\x00' \
+            b'\xbc\xd3\x00\x00' b'\x6d\xcb\x00\x00' \
+            b'\x62\xf2\x00\x00' b'\x0c\xe5\x00\x00' \
+            b'\x02\x8b\xbd\x41' b'\x04\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ConfigureWindow._request.to_binary, (), self.req_args_0)
+        bin = request.ConfigureWindow._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -473,11 +481,11 @@
             'direction': 0,
             'window': 1132872732,
             }
-        self.req_bin_0 = '\x0d\x00\x02\x00' '\x1c\x44\x86\x43'
+        self.req_bin_0 = b'\x0d\x00\x02\x00' b'\x1c\x44\x86\x43'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CirculateWindow._request.to_binary, (), self.req_args_0)
+        bin = request.CirculateWindow._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -500,7 +508,7 @@
         self.req_args_0 = {
             'drawable': 2036121058,
             }
-        self.req_bin_0 = '\x0e\x00\x02\x00' '\xe2\xbd\x5c\x79'
+        self.req_bin_0 = b'\x0e\x00\x02\x00' b'\xe2\xbd\x5c\x79'
 
         self.reply_args_0 = {
             'width': 65264,
@@ -512,14 +520,14 @@
             'sequence_number': 36173,
             'height': 9014,
             }
-        self.reply_bin_0 = '\x01\xfd\x4d\x8d' '\x00\x00\x00\x00' \
-            '\xf2\xf9\x63\x1d' '\x90\x8e\xa2\xd0' \
-            '\xf0\xfe\x36\x23' '\xb8\x4d\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\xfd\x4d\x8d' b'\x00\x00\x00\x00' \
+            b'\xf2\xf9\x63\x1d' b'\x90\x8e\xa2\xd0' \
+            b'\xf0\xfe\x36\x23' b'\xb8\x4d\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetGeometry._request.to_binary, (), self.req_args_0)
+        bin = request.GetGeometry._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -537,7 +545,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetGeometry._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetGeometry._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -560,7 +568,7 @@
         self.req_args_0 = {
             'window': 884880831,
             }
-        self.req_bin_0 = '\x0f\x00\x02\x00' '\xbf\x35\xbe\x34'
+        self.req_bin_0 = b'\x0f\x00\x02\x00' b'\xbf\x35\xbe\x34'
 
         self.reply_args_0 = {
             'parent': 701348115,
@@ -568,18 +576,18 @@
             'children': [1089242139, 925689046, 1668140638, 775016596, 1024466546, 1245533043, 1733661379],
             'sequence_number': 10033,
             }
-        self.reply_bin_0 = '\x01\x00\x31\x27' '\x07\x00\x00\x00' \
-            '\x35\xea\xdf\x17' '\x13\xb9\xcd\x29' \
-            '\x07\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x1b\x84\xec\x40' '\xd6\xe4\x2c\x37' \
-            '\x5e\xce\x6d\x63' '\x94\xd0\x31\x2e' \
-            '\x72\x1e\x10\x3d' '\x73\x53\x3d\x4a' \
-            '\xc3\x92\x55\x67'
+        self.reply_bin_0 = b'\x01\x00\x31\x27' b'\x07\x00\x00\x00' \
+            b'\x35\xea\xdf\x17' b'\x13\xb9\xcd\x29' \
+            b'\x07\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x1b\x84\xec\x40' b'\xd6\xe4\x2c\x37' \
+            b'\x5e\xce\x6d\x63' b'\x94\xd0\x31\x2e' \
+            b'\x72\x1e\x10\x3d' b'\x73\x53\x3d\x4a' \
+            b'\xc3\x92\x55\x67'
 
 
     def testPackRequest0(self):
-        bin = apply(request.QueryTree._request.to_binary, (), self.req_args_0)
+        bin = request.QueryTree._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -597,7 +605,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.QueryTree._reply.to_binary, (), self.reply_args_0)
+        bin = request.QueryTree._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -621,22 +629,22 @@
             'name': 'fuzzy_prop',
             'only_if_exists': 0,
             }
-        self.req_bin_0 = '\x10\x00\x05\x00' '\x0a\x00\x00\x00' \
-            '\x66\x75\x7a\x7a' '\x79\x5f\x70\x72' \
-            '\x6f\x70\x00\x00'
+        self.req_bin_0 = b'\x10\x00\x05\x00' b'\x0a\x00\x00\x00' \
+            b'\x66\x75\x7a\x7a' b'\x79\x5f\x70\x72' \
+            b'\x6f\x70\x00\x00'
 
         self.reply_args_0 = {
             'sequence_number': 14401,
             'atom': 1112752381,
             }
-        self.reply_bin_0 = '\x01\x00\x41\x38' '\x00\x00\x00\x00' \
-            '\xfd\x40\x53\x42' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\x41\x38' b'\x00\x00\x00\x00' \
+            b'\xfd\x40\x53\x42' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.InternAtom._request.to_binary, (), self.req_args_0)
+        bin = request.InternAtom._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -654,7 +662,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.InternAtom._reply.to_binary, (), self.reply_args_0)
+        bin = request.InternAtom._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -677,21 +685,21 @@
         self.req_args_0 = {
             'atom': 1234624354,
             }
-        self.req_bin_0 = '\x11\x00\x02\x00' '\x62\xdf\x96\x49'
+        self.req_bin_0 = b'\x11\x00\x02\x00' b'\x62\xdf\x96\x49'
 
         self.reply_args_0 = {
             'name': 'WM_CLASS',
             'sequence_number': 2504,
             }
-        self.reply_bin_0 = '\x01\x00\xc8\x09' '\x02\x00\x00\x00' \
-            '\x08\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x57\x4d\x5f\x43' '\x4c\x41\x53\x53'
+        self.reply_bin_0 = b'\x01\x00\xc8\x09' b'\x02\x00\x00\x00' \
+            b'\x08\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x57\x4d\x5f\x43' b'\x4c\x41\x53\x53'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetAtomName._request.to_binary, (), self.req_args_0)
+        bin = request.GetAtomName._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -709,7 +717,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetAtomName._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetAtomName._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -736,9 +744,9 @@
             'data': (8, ''),
             'mode': 2,
             }
-        self.req_bin_0 = '\x12\x02\x06\x00' '\x25\x5d\xa4\x4a' \
-            '\x09\x59\x27\x0e' '\xb9\xcf\x2f\x48' \
-            '\x08\x00\x00\x00' '\x00\x00\x00\x00'
+        self.req_bin_0 = b'\x12\x02\x06\x00' b'\x25\x5d\xa4\x4a' \
+            b'\x09\x59\x27\x0e' b'\xb9\xcf\x2f\x48' \
+            b'\x08\x00\x00\x00' b'\x00\x00\x00\x00'
 
         self.req_args_1 = {
             'type': 347282449,
@@ -747,10 +755,10 @@
             'data': (8, 'foo'),
             'mode': 1,
             }
-        self.req_bin_1 = '\x12\x01\x07\x00' '\x19\xec\x86\x01' \
-            '\x25\x5d\xc9\x25' '\x11\x1c\xb3\x14' \
-            '\x08\x00\x00\x00' '\x03\x00\x00\x00' \
-            '\x66\x6f\x6f\x00'
+        self.req_bin_1 = b'\x12\x01\x07\x00' b'\x19\xec\x86\x01' \
+            b'\x25\x5d\xc9\x25' b'\x11\x1c\xb3\x14' \
+            b'\x08\x00\x00\x00' b'\x03\x00\x00\x00' \
+            b'\x66\x6f\x6f\x00'
 
         self.req_args_2 = {
             'type': 1524334051,
@@ -759,10 +767,10 @@
             'data': (8, 'zoom'),
             'mode': 1,
             }
-        self.req_bin_2 = '\x12\x01\x07\x00' '\xc0\xa6\xb7\x1c' \
-            '\xc5\x16\x42\x27' '\xe3\x7d\xdb\x5a' \
-            '\x08\x00\x00\x00' '\x04\x00\x00\x00' \
-            '\x7a\x6f\x6f\x6d'
+        self.req_bin_2 = b'\x12\x01\x07\x00' b'\xc0\xa6\xb7\x1c' \
+            b'\xc5\x16\x42\x27' b'\xe3\x7d\xdb\x5a' \
+            b'\x08\x00\x00\x00' b'\x04\x00\x00\x00' \
+            b'\x7a\x6f\x6f\x6d'
 
         self.req_args_3 = {
             'type': 1895805524,
@@ -771,9 +779,9 @@
             'data': (16, []),
             'mode': 2,
             }
-        self.req_bin_3 = '\x12\x02\x06\x00' '\x13\xde\x9c\x0c' \
-            '\xee\xa7\x9f\x01' '\x54\xb2\xff\x70' \
-            '\x10\x00\x00\x00' '\x00\x00\x00\x00'
+        self.req_bin_3 = b'\x12\x02\x06\x00' b'\x13\xde\x9c\x0c' \
+            b'\xee\xa7\x9f\x01' b'\x54\xb2\xff\x70' \
+            b'\x10\x00\x00\x00' b'\x00\x00\x00\x00'
 
         self.req_args_4 = {
             'type': 549788841,
@@ -782,10 +790,10 @@
             'data': (16, [1, 2, 3]),
             'mode': 0,
             }
-        self.req_bin_4 = '\x12\x00\x08\x00' '\x3c\x4c\x4d\x59' \
-            '\x31\x43\x70\x6f' '\xa9\x1c\xc5\x20' \
-            '\x10\x00\x00\x00' '\x03\x00\x00\x00' \
-            '\x01\x00\x02\x00' '\x03\x00\x00\x00'
+        self.req_bin_4 = b'\x12\x00\x08\x00' b'\x3c\x4c\x4d\x59' \
+            b'\x31\x43\x70\x6f' b'\xa9\x1c\xc5\x20' \
+            b'\x10\x00\x00\x00' b'\x03\x00\x00\x00' \
+            b'\x01\x00\x02\x00' b'\x03\x00\x00\x00'
 
         self.req_args_5 = {
             'type': 1083661140,
@@ -794,10 +802,10 @@
             'data': (16, [1, 2, 3, 4]),
             'mode': 2,
             }
-        self.req_bin_5 = '\x12\x02\x08\x00' '\x66\x3b\x5c\x78' \
-            '\x8f\x6c\x80\x17' '\x54\x5b\x97\x40' \
-            '\x10\x00\x00\x00' '\x04\x00\x00\x00' \
-            '\x01\x00\x02\x00' '\x03\x00\x04\x00'
+        self.req_bin_5 = b'\x12\x02\x08\x00' b'\x66\x3b\x5c\x78' \
+            b'\x8f\x6c\x80\x17' b'\x54\x5b\x97\x40' \
+            b'\x10\x00\x00\x00' b'\x04\x00\x00\x00' \
+            b'\x01\x00\x02\x00' b'\x03\x00\x04\x00'
 
         self.req_args_6 = {
             'type': 761479544,
@@ -806,9 +814,9 @@
             'data': (32, []),
             'mode': 2,
             }
-        self.req_bin_6 = '\x12\x02\x06\x00' '\x91\x3e\xf2\x4b' \
-            '\xe1\x3f\xf1\x67' '\x78\x41\x63\x2d' \
-            '\x20\x00\x00\x00' '\x00\x00\x00\x00'
+        self.req_bin_6 = b'\x12\x02\x06\x00' b'\x91\x3e\xf2\x4b' \
+            b'\xe1\x3f\xf1\x67' b'\x78\x41\x63\x2d' \
+            b'\x20\x00\x00\x00' b'\x00\x00\x00\x00'
 
         self.req_args_7 = {
             'type': 956119085,
@@ -817,15 +825,15 @@
             'data': (32, [1, 2, 3]),
             'mode': 1,
             }
-        self.req_bin_7 = '\x12\x01\x09\x00' '\x91\x5c\xb8\x3c' \
-            '\xbe\x5c\xe4\x28' '\x2d\x38\xfd\x38' \
-            '\x20\x00\x00\x00' '\x03\x00\x00\x00' \
-            '\x01\x00\x00\x00' '\x02\x00\x00\x00' \
-            '\x03\x00\x00\x00'
+        self.req_bin_7 = b'\x12\x01\x09\x00' b'\x91\x5c\xb8\x3c' \
+            b'\xbe\x5c\xe4\x28' b'\x2d\x38\xfd\x38' \
+            b'\x20\x00\x00\x00' b'\x03\x00\x00\x00' \
+            b'\x01\x00\x00\x00' b'\x02\x00\x00\x00' \
+            b'\x03\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_0)
+        bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -843,7 +851,7 @@
             raise AssertionError(args)
 
     def testPackRequest1(self):
-        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_1)
+        bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_1)
         try:
             assert bin == self.req_bin_1
         except AssertionError:
@@ -861,7 +869,7 @@
             raise AssertionError(args)
 
     def testPackRequest2(self):
-        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_2)
+        bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_2)
         try:
             assert bin == self.req_bin_2
         except AssertionError:
@@ -879,7 +887,7 @@
             raise AssertionError(args)
 
     def testPackRequest3(self):
-        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_3)
+        bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_3)
         try:
             assert bin == self.req_bin_3
         except AssertionError:
@@ -897,7 +905,7 @@
             raise AssertionError(args)
 
     def testPackRequest4(self):
-        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_4)
+        bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_4)
         try:
             assert bin == self.req_bin_4
         except AssertionError:
@@ -915,7 +923,7 @@
             raise AssertionError(args)
 
     def testPackRequest5(self):
-        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_5)
+        bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_5)
         try:
             assert bin == self.req_bin_5
         except AssertionError:
@@ -933,7 +941,7 @@
             raise AssertionError(args)
 
     def testPackRequest6(self):
-        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_6)
+        bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_6)
         try:
             assert bin == self.req_bin_6
         except AssertionError:
@@ -951,7 +959,7 @@
             raise AssertionError(args)
 
     def testPackRequest7(self):
-        bin = apply(request.ChangeProperty._request.to_binary, (), self.req_args_7)
+        bin = request.ChangeProperty._request.to_binary(*(), **self.req_args_7)
         try:
             assert bin == self.req_bin_7
         except AssertionError:
@@ -975,12 +983,12 @@
             'window': 1858113940,
             'property': 754854074,
             }
-        self.req_bin_0 = '\x13\x00\x03\x00' '\x94\x91\xc0\x6e' \
-            '\xba\x28\xfe\x2c'
+        self.req_bin_0 = b'\x13\x00\x03\x00' b'\x94\x91\xc0\x6e' \
+            b'\xba\x28\xfe\x2c'
 
 
     def testPackRequest0(self):
-        bin = apply(request.DeleteProperty._request.to_binary, (), self.req_args_0)
+        bin = request.DeleteProperty._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1008,9 +1016,9 @@
             'long_length': 1748032051,
             'delete': 0,
             }
-        self.req_bin_0 = '\x14\x00\x06\x00' '\xda\x26\xe0\x63' \
-            '\x92\x84\xda\x73' '\x2b\x75\x56\x0d' \
-            '\x90\x39\xaf\x00' '\x33\xda\x30\x68'
+        self.req_bin_0 = b'\x14\x00\x06\x00' b'\xda\x26\xe0\x63' \
+            b'\x92\x84\xda\x73' b'\x2b\x75\x56\x0d' \
+            b'\x90\x39\xaf\x00' b'\x33\xda\x30\x68'
 
         self.reply_args_0 = {
             'bytes_after': 1264377294,
@@ -1018,10 +1026,10 @@
             'sequence_number': 34281,
             'value': (8, ''),
             }
-        self.reply_bin_0 = '\x01\x08\xe9\x85' '\x00\x00\x00\x00' \
-            '\x02\xc9\xe6\x4d' '\xce\xdd\x5c\x4b' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x08\xe9\x85' b'\x00\x00\x00\x00' \
+            b'\x02\xc9\xe6\x4d' b'\xce\xdd\x5c\x4b' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
         self.reply_args_1 = {
             'bytes_after': 902042689,
@@ -1029,11 +1037,11 @@
             'sequence_number': 50371,
             'value': (8, 'foo'),
             }
-        self.reply_bin_1 = '\x01\x08\xc3\xc4' '\x01\x00\x00\x00' \
-            '\x13\x3f\x14\x6e' '\x41\x14\xc4\x35' \
-            '\x03\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x66\x6f\x6f\x00'
+        self.reply_bin_1 = b'\x01\x08\xc3\xc4' b'\x01\x00\x00\x00' \
+            b'\x13\x3f\x14\x6e' b'\x41\x14\xc4\x35' \
+            b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x66\x6f\x6f\x00'
 
         self.reply_args_2 = {
             'bytes_after': 1782597051,
@@ -1041,11 +1049,11 @@
             'sequence_number': 58679,
             'value': (8, 'zoom'),
             }
-        self.reply_bin_2 = '\x01\x08\x37\xe5' '\x01\x00\x00\x00' \
-            '\x47\xc4\x2e\x60' '\xbb\x45\x40\x6a' \
-            '\x04\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x7a\x6f\x6f\x6d'
+        self.reply_bin_2 = b'\x01\x08\x37\xe5' b'\x01\x00\x00\x00' \
+            b'\x47\xc4\x2e\x60' b'\xbb\x45\x40\x6a' \
+            b'\x04\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x7a\x6f\x6f\x6d'
 
         self.reply_args_3 = {
             'bytes_after': 1107167742,
@@ -1053,10 +1061,10 @@
             'sequence_number': 49647,
             'value': (16, []),
             }
-        self.reply_bin_3 = '\x01\x10\xef\xc1' '\x00\x00\x00\x00' \
-            '\xfa\x06\x1f\x75' '\xfe\x09\xfe\x41' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_3 = b'\x01\x10\xef\xc1' b'\x00\x00\x00\x00' \
+            b'\xfa\x06\x1f\x75' b'\xfe\x09\xfe\x41' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
         self.reply_args_4 = {
             'bytes_after': 1602466976,
@@ -1064,11 +1072,11 @@
             'sequence_number': 58268,
             'value': (16, [1, 2, 3]),
             }
-        self.reply_bin_4 = '\x01\x10\x9c\xe3' '\x02\x00\x00\x00' \
-            '\x24\x3d\x11\x26' '\xa0\xb4\x83\x5f' \
-            '\x03\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x01\x00\x02\x00' '\x03\x00\x00\x00'
+        self.reply_bin_4 = b'\x01\x10\x9c\xe3' b'\x02\x00\x00\x00' \
+            b'\x24\x3d\x11\x26' b'\xa0\xb4\x83\x5f' \
+            b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x01\x00\x02\x00' b'\x03\x00\x00\x00'
 
         self.reply_args_5 = {
             'bytes_after': 651542717,
@@ -1076,11 +1084,11 @@
             'sequence_number': 26901,
             'value': (16, [1, 2, 3, 4]),
             }
-        self.reply_bin_5 = '\x01\x10\x15\x69' '\x02\x00\x00\x00' \
-            '\xe6\x9d\x78\x38' '\xbd\xc0\xd5\x26' \
-            '\x04\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x01\x00\x02\x00' '\x03\x00\x04\x00'
+        self.reply_bin_5 = b'\x01\x10\x15\x69' b'\x02\x00\x00\x00' \
+            b'\xe6\x9d\x78\x38' b'\xbd\xc0\xd5\x26' \
+            b'\x04\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x01\x00\x02\x00' b'\x03\x00\x04\x00'
 
         self.reply_args_6 = {
             'bytes_after': 602498418,
@@ -1088,10 +1096,10 @@
             'sequence_number': 11175,
             'value': (32, []),
             }
-        self.reply_bin_6 = '\x01\x20\xa7\x2b' '\x00\x00\x00\x00' \
-            '\x7e\xa7\x98\x02' '\x72\x65\xe9\x23' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_6 = b'\x01\x20\xa7\x2b' b'\x00\x00\x00\x00' \
+            b'\x7e\xa7\x98\x02' b'\x72\x65\xe9\x23' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
         self.reply_args_7 = {
             'bytes_after': 1661909208,
@@ -1099,16 +1107,16 @@
             'sequence_number': 4347,
             'value': (32, [1, 2, 3]),
             }
-        self.reply_bin_7 = '\x01\x20\xfb\x10' '\x03\x00\x00\x00' \
-            '\x08\xf7\x2e\x24' '\xd8\xb8\x0e\x63' \
-            '\x03\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x01\x00\x00\x00' '\x02\x00\x00\x00' \
-            '\x03\x00\x00\x00'
+        self.reply_bin_7 = b'\x01\x20\xfb\x10' b'\x03\x00\x00\x00' \
+            b'\x08\xf7\x2e\x24' b'\xd8\xb8\x0e\x63' \
+            b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x01\x00\x00\x00' b'\x02\x00\x00\x00' \
+            b'\x03\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetProperty._request.to_binary, (), self.req_args_0)
+        bin = request.GetProperty._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1126,7 +1134,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -1144,7 +1152,7 @@
             raise AssertionError(args)
 
     def testPackReply1(self):
-        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_1)
+        bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_1)
         try:
             assert bin == self.reply_bin_1
         except AssertionError:
@@ -1162,7 +1170,7 @@
             raise AssertionError(args)
 
     def testPackReply2(self):
-        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_2)
+        bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_2)
         try:
             assert bin == self.reply_bin_2
         except AssertionError:
@@ -1180,7 +1188,7 @@
             raise AssertionError(args)
 
     def testPackReply3(self):
-        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_3)
+        bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_3)
         try:
             assert bin == self.reply_bin_3
         except AssertionError:
@@ -1198,7 +1206,7 @@
             raise AssertionError(args)
 
     def testPackReply4(self):
-        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_4)
+        bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_4)
         try:
             assert bin == self.reply_bin_4
         except AssertionError:
@@ -1216,7 +1224,7 @@
             raise AssertionError(args)
 
     def testPackReply5(self):
-        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_5)
+        bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_5)
         try:
             assert bin == self.reply_bin_5
         except AssertionError:
@@ -1234,7 +1242,7 @@
             raise AssertionError(args)
 
     def testPackReply6(self):
-        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_6)
+        bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_6)
         try:
             assert bin == self.reply_bin_6
         except AssertionError:
@@ -1252,7 +1260,7 @@
             raise AssertionError(args)
 
     def testPackReply7(self):
-        bin = apply(request.GetProperty._reply.to_binary, (), self.reply_args_7)
+        bin = request.GetProperty._reply.to_binary(*(), **self.reply_args_7)
         try:
             assert bin == self.reply_bin_7
         except AssertionError:
@@ -1275,32 +1283,32 @@
         self.req_args_0 = {
             'window': 1002132678,
             }
-        self.req_bin_0 = '\x15\x00\x02\x00' '\xc6\x54\xbb\x3b'
+        self.req_bin_0 = b'\x15\x00\x02\x00' b'\xc6\x54\xbb\x3b'
 
         self.reply_args_0 = {
             'sequence_number': 58554,
             'atoms': [497337753, 1561366096, 1429910722, 371682445, 1693790956, 124266489, 819023111, 1575252239, 1958056613, 76461795, 2044963121, 1187630009, 890357857, 639310702, 1708479530, 336050724, 1163834063, 1164094286, 1626309474, 136351014, 1163110454, 1416739018, 1380223836],
             }
-        self.reply_bin_0 = '\x01\x00\xba\xe4' '\x17\x00\x00\x00' \
-            '\x17\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x99\xc5\xa4\x1d' '\x50\x8e\x10\x5d' \
-            '\xc2\xb4\x3a\x55' '\x8d\x6c\x27\x16' \
-            '\xec\x32\xf5\x64' '\xf9\x27\x68\x07' \
-            '\x07\x4d\xd1\x30' '\x0f\x71\xe4\x5d' \
-            '\xa5\x92\xb5\x74' '\xe3\xb6\x8e\x04' \
-            '\x31\xa9\xe3\x79' '\xb9\xcb\xc9\x46' \
-            '\x61\xc8\x11\x35' '\x6e\x1b\x1b\x26' \
-            '\x2a\x54\xd5\x65' '\x24\xba\x07\x14' \
-            '\xcf\xb2\x5e\x45' '\x4e\xab\x62\x45' \
-            '\x62\x83\xef\x60' '\x26\x8d\x20\x08' \
-            '\x36\xa8\x53\x45' '\xca\xb8\x71\x54' \
-            '\x5c\x8b\x44\x52'
+        self.reply_bin_0 = b'\x01\x00\xba\xe4' b'\x17\x00\x00\x00' \
+            b'\x17\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x99\xc5\xa4\x1d' b'\x50\x8e\x10\x5d' \
+            b'\xc2\xb4\x3a\x55' b'\x8d\x6c\x27\x16' \
+            b'\xec\x32\xf5\x64' b'\xf9\x27\x68\x07' \
+            b'\x07\x4d\xd1\x30' b'\x0f\x71\xe4\x5d' \
+            b'\xa5\x92\xb5\x74' b'\xe3\xb6\x8e\x04' \
+            b'\x31\xa9\xe3\x79' b'\xb9\xcb\xc9\x46' \
+            b'\x61\xc8\x11\x35' b'\x6e\x1b\x1b\x26' \
+            b'\x2a\x54\xd5\x65' b'\x24\xba\x07\x14' \
+            b'\xcf\xb2\x5e\x45' b'\x4e\xab\x62\x45' \
+            b'\x62\x83\xef\x60' b'\x26\x8d\x20\x08' \
+            b'\x36\xa8\x53\x45' b'\xca\xb8\x71\x54' \
+            b'\x5c\x8b\x44\x52'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ListProperties._request.to_binary, (), self.req_args_0)
+        bin = request.ListProperties._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1318,7 +1326,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.ListProperties._reply.to_binary, (), self.reply_args_0)
+        bin = request.ListProperties._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -1343,12 +1351,12 @@
             'selection': 984224380,
             'time': 2112448956,
             }
-        self.req_bin_0 = '\x16\x00\x04\x00' '\x4d\x88\xcd\x5d' \
-            '\x7c\x12\xaa\x3a' '\xbc\x69\xe9\x7d'
+        self.req_bin_0 = b'\x16\x00\x04\x00' b'\x4d\x88\xcd\x5d' \
+            b'\x7c\x12\xaa\x3a' b'\xbc\x69\xe9\x7d'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetSelectionOwner._request.to_binary, (), self.req_args_0)
+        bin = request.SetSelectionOwner._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1371,20 +1379,20 @@
         self.req_args_0 = {
             'selection': 1209066471,
             }
-        self.req_bin_0 = '\x17\x00\x02\x00' '\xe7\xe3\x10\x48'
+        self.req_bin_0 = b'\x17\x00\x02\x00' b'\xe7\xe3\x10\x48'
 
         self.reply_args_0 = {
             'owner': 1608499874,
             'sequence_number': 40856,
             }
-        self.reply_bin_0 = '\x01\x00\x98\x9f' '\x00\x00\x00\x00' \
-            '\xa2\xc2\xdf\x5f' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\x98\x9f' b'\x00\x00\x00\x00' \
+            b'\xa2\xc2\xdf\x5f' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetSelectionOwner._request.to_binary, (), self.req_args_0)
+        bin = request.GetSelectionOwner._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1402,7 +1410,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetSelectionOwner._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetSelectionOwner._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -1429,13 +1437,13 @@
             'target': 1621875689,
             'time': 385931637,
             }
-        self.req_bin_0 = '\x18\x00\x06\x00' '\x51\x10\xc4\x09' \
-            '\xbe\x15\xaf\x0e' '\xe9\xdb\xab\x60' \
-            '\x0f\x2b\xee\x06' '\x75\xd9\x00\x17'
+        self.req_bin_0 = b'\x18\x00\x06\x00' b'\x51\x10\xc4\x09' \
+            b'\xbe\x15\xaf\x0e' b'\xe9\xdb\xab\x60' \
+            b'\x0f\x2b\xee\x06' b'\x75\xd9\x00\x17'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ConvertSelection._request.to_binary, (), self.req_args_0)
+        bin = request.ConvertSelection._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1461,16 +1469,16 @@
             'propagate': 1,
             'event': Xlib.protocol.event.Expose(count = 7721, width = 18606, window = 1339231972, y = 45287, x = 46510, type = 12, sequence_number = 0, height = 44735),
             }
-        self.req_bin_0 = '\x19\x01\x0b\x00' '\xd8\xda\x29\x62' \
-            '\x50\xdb\xc4\x3a' '\x0c\x00\x00\x00' \
-            '\xe4\x0e\xd3\x4f' '\xae\xb5\xe7\xb0' \
-            '\xae\x48\xbf\xae' '\x29\x1e\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00'
+        self.req_bin_0 = b'\x19\x01\x0b\x00' b'\xd8\xda\x29\x62' \
+            b'\x50\xdb\xc4\x3a' b'\x0c\x00\x00\x00' \
+            b'\xe4\x0e\xd3\x4f' b'\xae\xb5\xe7\xb0' \
+            b'\xae\x48\xbf\xae' b'\x29\x1e\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SendEvent._request.to_binary, (), self.req_args_0)
+        bin = request.SendEvent._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1500,22 +1508,22 @@
             'grab_window': 1295558486,
             'owner_events': 1,
             }
-        self.req_bin_0 = '\x1a\x01\x06\x00' '\x56\xa7\x38\x4d' \
-            '\x12\x6b\x01\x00' '\xca\xe1\x02\x5b' \
-            '\xe7\xde\xb2\x69' '\xa7\xfa\x3e\x47'
+        self.req_bin_0 = b'\x1a\x01\x06\x00' b'\x56\xa7\x38\x4d' \
+            b'\x12\x6b\x01\x00' b'\xca\xe1\x02\x5b' \
+            b'\xe7\xde\xb2\x69' b'\xa7\xfa\x3e\x47'
 
         self.reply_args_0 = {
             'status': 166,
             'sequence_number': 9454,
             }
-        self.reply_bin_0 = '\x01\xa6\xee\x24' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\xa6\xee\x24' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GrabPointer._request.to_binary, (), self.req_args_0)
+        bin = request.GrabPointer._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1533,7 +1541,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GrabPointer._reply.to_binary, (), self.reply_args_0)
+        bin = request.GrabPointer._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -1556,11 +1564,11 @@
         self.req_args_0 = {
             'time': 1647345145,
             }
-        self.req_bin_0 = '\x1b\x00\x02\x00' '\xf9\x7d\x30\x62'
+        self.req_bin_0 = b'\x1b\x00\x02\x00' b'\xf9\x7d\x30\x62'
 
 
     def testPackRequest0(self):
-        bin = apply(request.UngrabPointer._request.to_binary, (), self.req_args_0)
+        bin = request.UngrabPointer._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1591,13 +1599,13 @@
             'grab_window': 2055413885,
             'owner_events': 0,
             }
-        self.req_bin_0 = '\x1c\x00\x06\x00' '\x7d\x20\x83\x7a' \
-            '\xa4\x5c\x01\x00' '\xa3\x8d\xf5\x7a' \
-            '\xd9\x94\x06\x5a' '\xa9\x00\x95\xf4'
+        self.req_bin_0 = b'\x1c\x00\x06\x00' b'\x7d\x20\x83\x7a' \
+            b'\xa4\x5c\x01\x00' b'\xa3\x8d\xf5\x7a' \
+            b'\xd9\x94\x06\x5a' b'\xa9\x00\x95\xf4'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GrabButton._request.to_binary, (), self.req_args_0)
+        bin = request.GrabButton._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1622,12 +1630,12 @@
             'modifiers': 32389,
             'grab_window': 1891977189,
             }
-        self.req_bin_0 = '\x1d\xdc\x03\x00' '\xe5\x47\xc5\x70' \
-            '\x85\x7e\x00\x00'
+        self.req_bin_0 = b'\x1d\xdc\x03\x00' b'\xe5\x47\xc5\x70' \
+            b'\x85\x7e\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.UngrabButton._request.to_binary, (), self.req_args_0)
+        bin = request.UngrabButton._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1652,12 +1660,12 @@
             'event_mask': 12743,
             'time': 197998305,
             }
-        self.req_bin_0 = '\x1e\x00\x04\x00' '\x0c\xd9\x5e\x2e' \
-            '\xe1\x36\xcd\x0b' '\xc7\x31\x00\x00'
+        self.req_bin_0 = b'\x1e\x00\x04\x00' b'\x0c\xd9\x5e\x2e' \
+            b'\xe1\x36\xcd\x0b' b'\xc7\x31\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangeActivePointerGrab._request.to_binary, (), self.req_args_0)
+        bin = request.ChangeActivePointerGrab._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1684,21 +1692,21 @@
             'grab_window': 316814295,
             'owner_events': 0,
             }
-        self.req_bin_0 = '\x1f\x00\x04\x00' '\xd7\x33\xe2\x12' \
-            '\x93\x11\x1d\x65' '\x00\x01\x00\x00'
+        self.req_bin_0 = b'\x1f\x00\x04\x00' b'\xd7\x33\xe2\x12' \
+            b'\x93\x11\x1d\x65' b'\x00\x01\x00\x00'
 
         self.reply_args_0 = {
             'status': 239,
             'sequence_number': 46747,
             }
-        self.reply_bin_0 = '\x01\xef\x9b\xb6' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\xef\x9b\xb6' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GrabKeyboard._request.to_binary, (), self.req_args_0)
+        bin = request.GrabKeyboard._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1716,7 +1724,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GrabKeyboard._reply.to_binary, (), self.reply_args_0)
+        bin = request.GrabKeyboard._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -1739,11 +1747,11 @@
         self.req_args_0 = {
             'time': 4211611,
             }
-        self.req_bin_0 = '\x20\x00\x02\x00' '\x9b\x43\x40\x00'
+        self.req_bin_0 = b'\x20\x00\x02\x00' b'\x9b\x43\x40\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.UngrabKeyboard._request.to_binary, (), self.req_args_0)
+        bin = request.UngrabKeyboard._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1771,12 +1779,12 @@
             'grab_window': 882662093,
             'owner_events': 1,
             }
-        self.req_bin_0 = '\x21\x01\x04\x00' '\xcd\x5a\x9c\x34' \
-            '\x37\xf2\xaf\x00' '\x00\x00\x00\x00'
+        self.req_bin_0 = b'\x21\x01\x04\x00' b'\xcd\x5a\x9c\x34' \
+            b'\x37\xf2\xaf\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GrabKey._request.to_binary, (), self.req_args_0)
+        bin = request.GrabKey._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1801,12 +1809,12 @@
             'grab_window': 1389213966,
             'key': 141,
             }
-        self.req_bin_0 = '\x22\x8d\x03\x00' '\x0e\xb9\xcd\x52' \
-            '\x9e\x48\x00\x00'
+        self.req_bin_0 = b'\x22\x8d\x03\x00' b'\x0e\xb9\xcd\x52' \
+            b'\x9e\x48\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.UngrabKey._request.to_binary, (), self.req_args_0)
+        bin = request.UngrabKey._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1830,11 +1838,11 @@
             'mode': 7,
             'time': 1088990319,
             }
-        self.req_bin_0 = '\x23\x07\x02\x00' '\x6f\xac\xe8\x40'
+        self.req_bin_0 = b'\x23\x07\x02\x00' b'\x6f\xac\xe8\x40'
 
 
     def testPackRequest0(self):
-        bin = apply(request.AllowEvents._request.to_binary, (), self.req_args_0)
+        bin = request.AllowEvents._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1856,11 +1864,11 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x24\x00\x01\x00'
+        self.req_bin_0 = b'\x24\x00\x01\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GrabServer._request.to_binary, (), self.req_args_0)
+        bin = request.GrabServer._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1882,11 +1890,11 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x25\x00\x01\x00'
+        self.req_bin_0 = b'\x25\x00\x01\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.UngrabServer._request.to_binary, (), self.req_args_0)
+        bin = request.UngrabServer._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1909,7 +1917,7 @@
         self.req_args_0 = {
             'window': 358895460,
             }
-        self.req_bin_0 = '\x26\x00\x02\x00' '\x64\x4f\x64\x15'
+        self.req_bin_0 = b'\x26\x00\x02\x00' b'\x64\x4f\x64\x15'
 
         self.reply_args_0 = {
             'same_screen': 1,
@@ -1922,14 +1930,14 @@
             'sequence_number': 29530,
             'win_y': -19690,
             }
-        self.reply_bin_0 = '\x01\x01\x5a\x73' '\x00\x00\x00\x00' \
-            '\x34\xa3\x7b\x6e' '\x9e\xaa\x8d\x7f' \
-            '\x9d\xf6\x0e\xb8' '\x03\x88\x16\xb3' \
-            '\x96\x38\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x01\x5a\x73' b'\x00\x00\x00\x00' \
+            b'\x34\xa3\x7b\x6e' b'\x9e\xaa\x8d\x7f' \
+            b'\x9d\xf6\x0e\xb8' b'\x03\x88\x16\xb3' \
+            b'\x96\x38\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.QueryPointer._request.to_binary, (), self.req_args_0)
+        bin = request.QueryPointer._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -1947,7 +1955,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.QueryPointer._reply.to_binary, (), self.reply_args_0)
+        bin = request.QueryPointer._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -1972,26 +1980,26 @@
             'window': 528148429,
             'stop': 1808786083,
             }
-        self.req_bin_0 = '\x27\x00\x04\x00' '\xcd\xe7\x7a\x1f' \
-            '\x7d\xa5\xc9\x7d' '\xa3\xe2\xcf\x6b'
+        self.req_bin_0 = b'\x27\x00\x04\x00' b'\xcd\xe7\x7a\x1f' \
+            b'\x7d\xa5\xc9\x7d' b'\xa3\xe2\xcf\x6b'
 
         self.reply_args_0 = {
             'events': [{'y': -23108, 'x': -3461, 'time': 984326273}, {'y': -4096, 'x': -4908, 'time': 488459157}, {'y': -29782, 'x': -8325, 'time': 1162935901}, {'y': -26418, 'x': -10559, 'time': 275816904}, {'y': -3941, 'x': -2216, 'time': 656439277}],
             'sequence_number': 42652,
             }
-        self.reply_bin_0 = '\x01\x00\x9c\xa6' '\x0a\x00\x00\x00' \
-            '\x05\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x81\xa0\xab\x3a' '\x7b\xf2\xbc\xa5' \
-            '\x95\x4b\x1d\x1d' '\xd4\xec\x00\xf0' \
-            '\x5d\xfe\x50\x45' '\x7b\xdf\xaa\x8b' \
-            '\xc8\xa1\x70\x10' '\xc1\xd6\xce\x98' \
-            '\xed\x77\x20\x27' '\x58\xf7\x9b\xf0'
+        self.reply_bin_0 = b'\x01\x00\x9c\xa6' b'\x0a\x00\x00\x00' \
+            b'\x05\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x81\xa0\xab\x3a' b'\x7b\xf2\xbc\xa5' \
+            b'\x95\x4b\x1d\x1d' b'\xd4\xec\x00\xf0' \
+            b'\x5d\xfe\x50\x45' b'\x7b\xdf\xaa\x8b' \
+            b'\xc8\xa1\x70\x10' b'\xc1\xd6\xce\x98' \
+            b'\xed\x77\x20\x27' b'\x58\xf7\x9b\xf0'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetMotionEvents._request.to_binary, (), self.req_args_0)
+        bin = request.GetMotionEvents._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2009,7 +2017,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetMotionEvents._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetMotionEvents._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2035,8 +2043,8 @@
             'src_x': -18176,
             'src_y': -309,
             }
-        self.req_bin_0 = '\x28\x00\x04\x00' '\x8d\xc6\x9e\x4a' \
-            '\xf0\x4f\xaa\x0e' '\x00\xb9\xcb\xfe'
+        self.req_bin_0 = b'\x28\x00\x04\x00' b'\x8d\xc6\x9e\x4a' \
+            b'\xf0\x4f\xaa\x0e' b'\x00\xb9\xcb\xfe'
 
         self.reply_args_0 = {
             'y': -24269,
@@ -2045,14 +2053,14 @@
             'same_screen': 0,
             'child': 1548917071,
             }
-        self.reply_bin_0 = '\x01\x00\x5b\x9a' '\x00\x00\x00\x00' \
-            '\x4f\x99\x52\x5c' '\xca\x8b\x33\xa1' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\x5b\x9a' b'\x00\x00\x00\x00' \
+            b'\x4f\x99\x52\x5c' b'\xca\x8b\x33\xa1' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.TranslateCoords._request.to_binary, (), self.req_args_0)
+        bin = request.TranslateCoords._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2070,7 +2078,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.TranslateCoords._reply.to_binary, (), self.reply_args_0)
+        bin = request.TranslateCoords._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2100,13 +2108,13 @@
             'dst_window': 2139748563,
             'src_window': 1945176770,
             }
-        self.req_bin_0 = '\x29\x00\x06\x00' '\xc2\x0a\xf1\x73' \
-            '\xd3\xf8\x89\x7f' '\xd6\xfa\x4a\xcc' \
-            '\x49\xb0\x03\x21' '\x62\xc3\xf7\x99'
+        self.req_bin_0 = b'\x29\x00\x06\x00' b'\xc2\x0a\xf1\x73' \
+            b'\xd3\xf8\x89\x7f' b'\xd6\xfa\x4a\xcc' \
+            b'\x49\xb0\x03\x21' b'\x62\xc3\xf7\x99'
 
 
     def testPackRequest0(self):
-        bin = apply(request.WarpPointer._request.to_binary, (), self.req_args_0)
+        bin = request.WarpPointer._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2131,12 +2139,12 @@
             'focus': 1068495705,
             'time': 342883486,
             }
-        self.req_bin_0 = '\x2a\x00\x03\x00' '\x59\xf3\xaf\x3f' \
-            '\x9e\xfc\x6f\x14'
+        self.req_bin_0 = b'\x2a\x00\x03\x00' b'\x59\xf3\xaf\x3f' \
+            b'\x9e\xfc\x6f\x14'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetInputFocus._request.to_binary, (), self.req_args_0)
+        bin = request.SetInputFocus._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2158,21 +2166,21 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x2b\x00\x01\x00'
+        self.req_bin_0 = b'\x2b\x00\x01\x00'
 
         self.reply_args_0 = {
             'revert_to': 129,
             'focus': 1884243837,
             'sequence_number': 9052,
             }
-        self.reply_bin_0 = '\x01\x81\x5c\x23' '\x00\x00\x00\x00' \
-            '\x7d\x47\x4f\x70' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x81\x5c\x23' b'\x00\x00\x00\x00' \
+            b'\x7d\x47\x4f\x70' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetInputFocus._request.to_binary, (), self.req_args_0)
+        bin = request.GetInputFocus._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2190,7 +2198,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetInputFocus._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetInputFocus._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2212,21 +2220,21 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x2c\x00\x01\x00'
+        self.req_bin_0 = b'\x2c\x00\x01\x00'
 
         self.reply_args_0 = {
             'map': [175, 212, 207, 139, 156, 192, 230, 219, 136, 198, 152, 156, 229, 233, 221, 209, 131, 229, 209, 249, 130, 189, 183, 135, 238, 149, 131, 204, 162, 229, 149, 246],
             'sequence_number': 19383,
             }
-        self.reply_bin_0 = '\x01\x00\xb7\x4b' '\x02\x00\x00\x00' \
-            '\xaf\xd4\xcf\x8b' '\x9c\xc0\xe6\xdb' \
-            '\x88\xc6\x98\x9c' '\xe5\xe9\xdd\xd1' \
-            '\x83\xe5\xd1\xf9' '\x82\xbd\xb7\x87' \
-            '\xee\x95\x83\xcc' '\xa2\xe5\x95\xf6'
+        self.reply_bin_0 = b'\x01\x00\xb7\x4b' b'\x02\x00\x00\x00' \
+            b'\xaf\xd4\xcf\x8b' b'\x9c\xc0\xe6\xdb' \
+            b'\x88\xc6\x98\x9c' b'\xe5\xe9\xdd\xd1' \
+            b'\x83\xe5\xd1\xf9' b'\x82\xbd\xb7\x87' \
+            b'\xee\x95\x83\xcc' b'\xa2\xe5\x95\xf6'
 
 
     def testPackRequest0(self):
-        bin = apply(request.QueryKeymap._request.to_binary, (), self.req_args_0)
+        bin = request.QueryKeymap._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2244,7 +2252,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.QueryKeymap._reply.to_binary, (), self.reply_args_0)
+        bin = request.QueryKeymap._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2268,13 +2276,13 @@
             'name': 'foofont',
             'fid': 1809550053,
             }
-        self.req_bin_0 = '\x2d\x00\x05\x00' '\xe5\x8a\xdb\x6b' \
-            '\x07\x00\x00\x00' '\x66\x6f\x6f\x66' \
-            '\x6f\x6e\x74\x00'
+        self.req_bin_0 = b'\x2d\x00\x05\x00' b'\xe5\x8a\xdb\x6b' \
+            b'\x07\x00\x00\x00' b'\x66\x6f\x6f\x66' \
+            b'\x6f\x6e\x74\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.OpenFont._request.to_binary, (), self.req_args_0)
+        bin = request.OpenFont._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2297,11 +2305,11 @@
         self.req_args_0 = {
             'font': 405865016,
             }
-        self.req_bin_0 = '\x2e\x00\x02\x00' '\x38\x02\x31\x18'
+        self.req_bin_0 = b'\x2e\x00\x02\x00' b'\x38\x02\x31\x18'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CloseFont._request.to_binary, (), self.req_args_0)
+        bin = request.CloseFont._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2324,7 +2332,7 @@
         self.req_args_0 = {
             'font': 173413537,
             }
-        self.req_bin_0 = '\x2f\x00\x02\x00' '\xa1\x14\x56\x0a'
+        self.req_bin_0 = b'\x2f\x00\x02\x00' b'\xa1\x14\x56\x0a'
 
         self.reply_args_0 = {
             'max_bounds': {'left_side_bearing': -27346, 'descent': -13574, 'right_side_bearing': -29649, 'attributes': 58157, 'character_width': -6055, 'ascent': -4810},
@@ -2342,23 +2350,23 @@
             'properties': [{'name': 515636466, 'value': 1798456662}],
             'sequence_number': 52469,
             }
-        self.reply_bin_0 = '\x01\x00\xf5\xcc' '\x12\x00\x00\x00' \
-            '\x29\xe0\xf8\x83' '\x64\xb3\x6c\xd9' \
-            '\x6d\x8f\xba\xcd' '\x00\x00\x00\x00' \
-            '\x2e\x95\x2f\x8c' '\x59\xe8\x36\xed' \
-            '\xfa\xca\x2d\xe3' '\x00\x00\x00\x00' \
-            '\x08\xd1\x0a\xbd' '\x13\x6f\x01\x00' \
-            '\xa5\xc3\xdb\x00' '\x1a\xc2\x6f\xfc' \
-            '\x03\x00\x00\x00' '\xf2\xfc\xbb\x1e' \
-            '\x56\x45\x32\x6b' '\xfe\xae\x3f\xf5' \
-            '\x3d\xd0\xc7\xc9' '\x40\xc4\xfb\xfb' \
-            '\xfe\xd5\x51\xda' '\x09\x97\x23\xd4' \
-            '\xa7\xf9\xa8\x74' '\x8e\x87\xaf\x93' \
-            '\x65\xef\x49\xd0' '\x50\xbe\x82\xde'
+        self.reply_bin_0 = b'\x01\x00\xf5\xcc' b'\x12\x00\x00\x00' \
+            b'\x29\xe0\xf8\x83' b'\x64\xb3\x6c\xd9' \
+            b'\x6d\x8f\xba\xcd' b'\x00\x00\x00\x00' \
+            b'\x2e\x95\x2f\x8c' b'\x59\xe8\x36\xed' \
+            b'\xfa\xca\x2d\xe3' b'\x00\x00\x00\x00' \
+            b'\x08\xd1\x0a\xbd' b'\x13\x6f\x01\x00' \
+            b'\xa5\xc3\xdb\x00' b'\x1a\xc2\x6f\xfc' \
+            b'\x03\x00\x00\x00' b'\xf2\xfc\xbb\x1e' \
+            b'\x56\x45\x32\x6b' b'\xfe\xae\x3f\xf5' \
+            b'\x3d\xd0\xc7\xc9' b'\x40\xc4\xfb\xfb' \
+            b'\xfe\xd5\x51\xda' b'\x09\x97\x23\xd4' \
+            b'\xa7\xf9\xa8\x74' b'\x8e\x87\xaf\x93' \
+            b'\x65\xef\x49\xd0' b'\x50\xbe\x82\xde'
 
 
     def testPackRequest0(self):
-        bin = apply(request.QueryFont._request.to_binary, (), self.req_args_0)
+        bin = request.QueryFont._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2376,7 +2384,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.QueryFont._reply.to_binary, (), self.reply_args_0)
+        bin = request.QueryFont._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2400,8 +2408,8 @@
             'font': 1637171782,
             'string': (102, 111, 111),
             }
-        self.req_bin_0 = '\x30\x01\x04\x00' '\x46\x42\x95\x61' \
-            '\x00\x66\x00\x6f' '\x00\x6f\x00\x00'
+        self.req_bin_0 = b'\x30\x01\x04\x00' b'\x46\x42\x95\x61' \
+            b'\x00\x66\x00\x6f' b'\x00\x6f\x00\x00'
 
         self.reply_args_0 = {
             'font_descent': -10581,
@@ -2414,14 +2422,14 @@
             'sequence_number': 6206,
             'overall_width': -127705892,
             }
-        self.reply_bin_0 = '\x01\xc3\x3e\x18' '\x00\x00\x00\x00' \
-            '\x45\xa6\xab\xd6' '\x72\x80\x6a\xb2' \
-            '\xdc\x5c\x63\xf8' '\x65\x3c\xb5\xb7' \
-            '\x9a\xb2\x7c\xcf' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\xc3\x3e\x18' b'\x00\x00\x00\x00' \
+            b'\x45\xa6\xab\xd6' b'\x72\x80\x6a\xb2' \
+            b'\xdc\x5c\x63\xf8' b'\x65\x3c\xb5\xb7' \
+            b'\x9a\xb2\x7c\xcf' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.QueryTextExtents._request.to_binary, (), self.req_args_0)
+        bin = request.QueryTextExtents._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2439,7 +2447,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.QueryTextExtents._reply.to_binary, (), self.reply_args_0)
+        bin = request.QueryTextExtents._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2463,24 +2471,24 @@
             'pattern': 'bhazr',
             'max_names': 57427,
             }
-        self.req_bin_0 = '\x31\x00\x04\x00' '\x53\xe0\x05\x00' \
-            '\x62\x68\x61\x7a' '\x72\x00\x00\x00'
+        self.req_bin_0 = b'\x31\x00\x04\x00' b'\x53\xe0\x05\x00' \
+            b'\x62\x68\x61\x7a' b'\x72\x00\x00\x00'
 
         self.reply_args_0 = {
             'fonts': ['fie', 'fuzzy', 'foozooom'],
             'sequence_number': 39409,
             }
-        self.reply_bin_0 = '\x01\x00\xf1\x99' '\x05\x00\x00\x00' \
-            '\x03\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x03\x66\x69\x65' '\x05\x66\x75\x7a' \
-            '\x7a\x79\x08\x66' '\x6f\x6f\x7a\x6f' \
-            '\x6f\x6f\x6d\x00'
+        self.reply_bin_0 = b'\x01\x00\xf1\x99' b'\x05\x00\x00\x00' \
+            b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x03\x66\x69\x65' b'\x05\x66\x75\x7a' \
+            b'\x7a\x79\x08\x66' b'\x6f\x6f\x7a\x6f' \
+            b'\x6f\x6f\x6d\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ListFonts._request.to_binary, (), self.req_args_0)
+        bin = request.ListFonts._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2498,7 +2506,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.ListFonts._reply.to_binary, (), self.reply_args_0)
+        bin = request.ListFonts._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2522,8 +2530,8 @@
             'pattern': 'bhazr2',
             'max_names': 52288,
             }
-        self.req_bin_0 = '\x32\x00\x04\x00' '\x40\xcc\x06\x00' \
-            '\x62\x68\x61\x7a' '\x72\x32\x00\x00'
+        self.req_bin_0 = b'\x32\x00\x04\x00' b'\x40\xcc\x06\x00' \
+            b'\x62\x68\x61\x7a' b'\x72\x32\x00\x00'
 
         self.reply_args_0 = {
             'max_bounds': {'left_side_bearing': -9255, 'descent': -26305, 'right_side_bearing': -6756, 'attributes': 49084, 'character_width': -4462, 'ascent': -3529},
@@ -2542,20 +2550,20 @@
             'properties': [{'name': 213588122, 'value': 1789263183}],
             'sequence_number': 43812,
             }
-        self.reply_bin_0 = '\x01\x08\x24\xab' '\x0b\x00\x00\x00' \
-            '\x62\xdf\x86\xb3' '\x5f\xae\x0c\xd9' \
-            '\xc4\xbd\xd8\x6a' '\x00\x00\x00\x00' \
-            '\xd9\xdb\x9c\xe5' '\x92\xee\x37\xf2' \
-            '\x3f\x99\xbc\xbf' '\x00\x00\x00\x00' \
-            '\x45\xfe\x72\xb0' '\x6b\x98\x01\x00' \
-            '\xe5\x9e\xdd\x01' '\xce\x96\x37\x9e' \
-            '\x27\x6f\x9c\x68' '\x9a\x18\xbb\x0c' \
-            '\x4f\xfd\xa5\x6a' '\x66\x6f\x6e\x74' \
-            '\x66\x6f\x6e\x74'
+        self.reply_bin_0 = b'\x01\x08\x24\xab' b'\x0b\x00\x00\x00' \
+            b'\x62\xdf\x86\xb3' b'\x5f\xae\x0c\xd9' \
+            b'\xc4\xbd\xd8\x6a' b'\x00\x00\x00\x00' \
+            b'\xd9\xdb\x9c\xe5' b'\x92\xee\x37\xf2' \
+            b'\x3f\x99\xbc\xbf' b'\x00\x00\x00\x00' \
+            b'\x45\xfe\x72\xb0' b'\x6b\x98\x01\x00' \
+            b'\xe5\x9e\xdd\x01' b'\xce\x96\x37\x9e' \
+            b'\x27\x6f\x9c\x68' b'\x9a\x18\xbb\x0c' \
+            b'\x4f\xfd\xa5\x6a' b'\x66\x6f\x6e\x74' \
+            b'\x66\x6f\x6e\x74'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ListFontsWithInfo._request.to_binary, (), self.req_args_0)
+        bin = request.ListFontsWithInfo._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2573,7 +2581,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.ListFontsWithInfo._reply.to_binary, (), self.reply_args_0)
+        bin = request.ListFontsWithInfo._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2596,18 +2604,18 @@
         self.req_args_0 = {
             'path': ['foo', 'bar', 'gazonk'],
             }
-        self.req_bin_0 = '\x33\x00\x06\x00' '\x03\x00\x00\x00' \
-            '\x03\x66\x6f\x6f' '\x03\x62\x61\x72' \
-            '\x06\x67\x61\x7a' '\x6f\x6e\x6b\x00'
+        self.req_bin_0 = b'\x33\x00\x06\x00' b'\x03\x00\x00\x00' \
+            b'\x03\x66\x6f\x6f' b'\x03\x62\x61\x72' \
+            b'\x06\x67\x61\x7a' b'\x6f\x6e\x6b\x00'
 
         self.req_args_1 = {
             'path': [],
             }
-        self.req_bin_1 = '\x33\x00\x02\x00' '\x00\x00\x00\x00'
+        self.req_bin_1 = b'\x33\x00\x02\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetFontPath._request.to_binary, (), self.req_args_0)
+        bin = request.SetFontPath._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2625,7 +2633,7 @@
             raise AssertionError(args)
 
     def testPackRequest1(self):
-        bin = apply(request.SetFontPath._request.to_binary, (), self.req_args_1)
+        bin = request.SetFontPath._request.to_binary(*(), **self.req_args_1)
         try:
             assert bin == self.req_bin_1
         except AssertionError:
@@ -2647,31 +2655,31 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x34\x00\x01\x00'
+        self.req_bin_0 = b'\x34\x00\x01\x00'
 
         self.reply_args_0 = {
             'paths': ['path1', 'path2232'],
             'sequence_number': 17086,
             }
-        self.reply_bin_0 = '\x01\x00\xbe\x42' '\x04\x00\x00\x00' \
-            '\x02\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x05\x70\x61\x74' '\x68\x31\x08\x70' \
-            '\x61\x74\x68\x32' '\x32\x33\x32\x00'
+        self.reply_bin_0 = b'\x01\x00\xbe\x42' b'\x04\x00\x00\x00' \
+            b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x05\x70\x61\x74' b'\x68\x31\x08\x70' \
+            b'\x61\x74\x68\x32' b'\x32\x33\x32\x00'
 
         self.reply_args_1 = {
             'paths': [],
             'sequence_number': 8511,
             }
-        self.reply_bin_1 = '\x01\x00\x3f\x21' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_1 = b'\x01\x00\x3f\x21' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetFontPath._request.to_binary, (), self.req_args_0)
+        bin = request.GetFontPath._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2689,7 +2697,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetFontPath._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetFontPath._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -2707,7 +2715,7 @@
             raise AssertionError(args)
 
     def testPackReply1(self):
-        bin = apply(request.GetFontPath._reply.to_binary, (), self.reply_args_1)
+        bin = request.GetFontPath._reply.to_binary(*(), **self.reply_args_1)
         try:
             assert bin == self.reply_bin_1
         except AssertionError:
@@ -2734,12 +2742,12 @@
             'drawable': 1358709134,
             'height': 16464,
             }
-        self.req_bin_0 = '\x35\xb3\x04\x00' '\x4a\xd5\x85\x32' \
-            '\x8e\x41\xfc\x50' '\x4c\x7e\x50\x40'
+        self.req_bin_0 = b'\x35\xb3\x04\x00' b'\x4a\xd5\x85\x32' \
+            b'\x8e\x41\xfc\x50' b'\x4c\x7e\x50\x40'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CreatePixmap._request.to_binary, (), self.req_args_0)
+        bin = request.CreatePixmap._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2762,11 +2770,11 @@
         self.req_args_0 = {
             'pixmap': 1323266674,
             }
-        self.req_bin_0 = '\x36\x00\x02\x00' '\x72\x72\xdf\x4e'
+        self.req_bin_0 = b'\x36\x00\x02\x00' b'\x72\x72\xdf\x4e'
 
 
     def testPackRequest0(self):
-        bin = apply(request.FreePixmap._request.to_binary, (), self.req_args_0)
+        bin = request.FreePixmap._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2791,24 +2799,24 @@
             'attrs': {'function': 14, 'foreground': 814230008, 'background': 2072616911, 'clip_x_origin': -6987, 'subwindow_mode': 0, 'cap_style': 1, 'fill_style': 3, 'tile_stipple_y_origin': -25870, 'font': 264499208, 'graphics_exposures': 0, 'join_style': 2, 'line_width': 36600, 'stipple': 870974399, 'dash_offset': 49599, 'clip_y_origin': -5712, 'tile_stipple_x_origin': -32365, 'arc_mode': 0, 'tile': 1597988019, 'line_style': 2, 'plane_mask': 1650697305, 'clip_mask': 402937862, 'fill_rule': 0, 'dashes': 136},
             'cid': 779296774,
             }
-        self.req_bin_0 = '\x37\x00\x1b\x00' '\x06\x20\x73\x2e' \
-            '\xb2\x9b\x7c\x31' '\xff\xff\x7f\x00' \
-            '\x0e\x00\x00\x00' '\x59\xa4\x63\x62' \
-            '\xf8\x29\x88\x30' '\xcf\x9f\x89\x7b' \
-            '\xf8\x8e\x00\x00' '\x02\x00\x00\x00' \
-            '\x01\x00\x00\x00' '\x02\x00\x00\x00' \
-            '\x03\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\xb3\x5c\x3f\x5f' '\xbf\x03\xea\x33' \
-            '\x93\x81\x00\x00' '\xf2\x9a\x00\x00' \
-            '\x08\xf0\xc3\x0f' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\xb5\xe4\x00\x00' \
-            '\xb0\xe9\x00\x00' '\x06\x58\x04\x18' \
-            '\xbf\xc1\x00\x00' '\x88\x00\x00\x00' \
-            '\x00\x00\x00\x00'
+        self.req_bin_0 = b'\x37\x00\x1b\x00' b'\x06\x20\x73\x2e' \
+            b'\xb2\x9b\x7c\x31' b'\xff\xff\x7f\x00' \
+            b'\x0e\x00\x00\x00' b'\x59\xa4\x63\x62' \
+            b'\xf8\x29\x88\x30' b'\xcf\x9f\x89\x7b' \
+            b'\xf8\x8e\x00\x00' b'\x02\x00\x00\x00' \
+            b'\x01\x00\x00\x00' b'\x02\x00\x00\x00' \
+            b'\x03\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\xb3\x5c\x3f\x5f' b'\xbf\x03\xea\x33' \
+            b'\x93\x81\x00\x00' b'\xf2\x9a\x00\x00' \
+            b'\x08\xf0\xc3\x0f' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\xb5\xe4\x00\x00' \
+            b'\xb0\xe9\x00\x00' b'\x06\x58\x04\x18' \
+            b'\xbf\xc1\x00\x00' b'\x88\x00\x00\x00' \
+            b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CreateGC._request.to_binary, (), self.req_args_0)
+        bin = request.CreateGC._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2832,23 +2840,23 @@
             'gc': 1996372624,
             'attrs': {'function': 15, 'foreground': 1817174045, 'background': 840850119, 'clip_x_origin': -28415, 'subwindow_mode': 1, 'cap_style': 0, 'fill_style': 0, 'tile_stipple_y_origin': -24832, 'font': 240535139, 'graphics_exposures': 1, 'join_style': 2, 'line_width': 64290, 'stipple': 1739313208, 'dash_offset': 53189, 'clip_y_origin': -2802, 'tile_stipple_x_origin': -4548, 'arc_mode': 1, 'tile': 1091199324, 'line_style': 2, 'plane_mask': 1403123174, 'clip_mask': 1604118463, 'fill_rule': 1, 'dashes': 186},
             }
-        self.req_bin_0 = '\x38\x00\x1a\x00' '\x90\x3a\xfe\x76' \
-            '\xff\xff\x7f\x00' '\x0f\x00\x00\x00' \
-            '\xe6\xf5\xa1\x53' '\x1d\xe0\x4f\x6c' \
-            '\xc7\x5a\x1e\x32' '\x22\xfb\x00\x00' \
-            '\x02\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x02\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x01\x00\x00\x00' '\x5c\x61\x0a\x41' \
-            '\x38\xd0\xab\x67' '\x3c\xee\x00\x00' \
-            '\x00\x9f\x00\x00' '\x63\x46\x56\x0e' \
-            '\x01\x00\x00\x00' '\x01\x00\x00\x00' \
-            '\x01\x91\x00\x00' '\x0e\xf5\x00\x00' \
-            '\xbf\xe7\x9c\x5f' '\xc5\xcf\x00\x00' \
-            '\xba\x00\x00\x00' '\x01\x00\x00\x00'
+        self.req_bin_0 = b'\x38\x00\x1a\x00' b'\x90\x3a\xfe\x76' \
+            b'\xff\xff\x7f\x00' b'\x0f\x00\x00\x00' \
+            b'\xe6\xf5\xa1\x53' b'\x1d\xe0\x4f\x6c' \
+            b'\xc7\x5a\x1e\x32' b'\x22\xfb\x00\x00' \
+            b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x01\x00\x00\x00' b'\x5c\x61\x0a\x41' \
+            b'\x38\xd0\xab\x67' b'\x3c\xee\x00\x00' \
+            b'\x00\x9f\x00\x00' b'\x63\x46\x56\x0e' \
+            b'\x01\x00\x00\x00' b'\x01\x00\x00\x00' \
+            b'\x01\x91\x00\x00' b'\x0e\xf5\x00\x00' \
+            b'\xbf\xe7\x9c\x5f' b'\xc5\xcf\x00\x00' \
+            b'\xba\x00\x00\x00' b'\x01\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangeGC._request.to_binary, (), self.req_args_0)
+        bin = request.ChangeGC._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2873,12 +2881,12 @@
             'dst_gc': 2046321491,
             'mask': 996538407,
             }
-        self.req_bin_0 = '\x39\x00\x04\x00' '\x3a\x47\xae\x5f' \
-            '\x53\x63\xf8\x79' '\x27\xf8\x65\x3b'
+        self.req_bin_0 = b'\x39\x00\x04\x00' b'\x3a\x47\xae\x5f' \
+            b'\x53\x63\xf8\x79' b'\x27\xf8\x65\x3b'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CopyGC._request.to_binary, (), self.req_args_0)
+        bin = request.CopyGC._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2903,13 +2911,13 @@
             'gc': 2119954025,
             'dashes': [146, 217, 181, 229, 212, 175, 201, 251, 248],
             }
-        self.req_bin_0 = '\x3a\x00\x06\x00' '\x69\xee\x5b\x7e' \
-            '\x8e\x88\x09\x00' '\x92\xd9\xb5\xe5' \
-            '\xd4\xaf\xc9\xfb' '\xf8\x00\x00\x00'
+        self.req_bin_0 = b'\x3a\x00\x06\x00' b'\x69\xee\x5b\x7e' \
+            b'\x8e\x88\x09\x00' b'\x92\xd9\xb5\xe5' \
+            b'\xd4\xaf\xc9\xfb' b'\xf8\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetDashes._request.to_binary, (), self.req_args_0)
+        bin = request.SetDashes._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2936,10 +2944,10 @@
             'rectangles': [{'y': -27524, 'x': -27245, 'height': 31014, 'width': 52432}, {'y': -8991, 'x': -11302, 'height': 9053, 'width': 11072}],
             'x_origin': -26003,
             }
-        self.req_bin_0 = '\x3b\x03\x07\x00' '\xc6\x91\xed\x78' \
-            '\x6d\x9a\x5e\xc3' '\x93\x95\x7c\x94' \
-            '\xd0\xcc\x26\x79' '\xda\xd3\xe1\xdc' \
-            '\x40\x2b\x5d\x23'
+        self.req_bin_0 = b'\x3b\x03\x07\x00' b'\xc6\x91\xed\x78' \
+            b'\x6d\x9a\x5e\xc3' b'\x93\x95\x7c\x94' \
+            b'\xd0\xcc\x26\x79' b'\xda\xd3\xe1\xdc' \
+            b'\x40\x2b\x5d\x23'
 
         self.req_args_1 = {
             'ordering': 1,
@@ -2948,12 +2956,12 @@
             'rectangles': [],
             'x_origin': -23382,
             }
-        self.req_bin_1 = '\x3b\x01\x03\x00' '\x8d\x63\x46\x09' \
-            '\xaa\xa4\x4a\x80'
+        self.req_bin_1 = b'\x3b\x01\x03\x00' b'\x8d\x63\x46\x09' \
+            b'\xaa\xa4\x4a\x80'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetClipRectangles._request.to_binary, (), self.req_args_0)
+        bin = request.SetClipRectangles._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -2971,7 +2979,7 @@
             raise AssertionError(args)
 
     def testPackRequest1(self):
-        bin = apply(request.SetClipRectangles._request.to_binary, (), self.req_args_1)
+        bin = request.SetClipRectangles._request.to_binary(*(), **self.req_args_1)
         try:
             assert bin == self.req_bin_1
         except AssertionError:
@@ -2994,11 +3002,11 @@
         self.req_args_0 = {
             'gc': 533809208,
             }
-        self.req_bin_0 = '\x3c\x00\x02\x00' '\x38\x48\xd1\x1f'
+        self.req_bin_0 = b'\x3c\x00\x02\x00' b'\x38\x48\xd1\x1f'
 
 
     def testPackRequest0(self):
-        bin = apply(request.FreeGC._request.to_binary, (), self.req_args_0)
+        bin = request.FreeGC._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3026,12 +3034,12 @@
             'exposures': 0,
             'height': 27400,
             }
-        self.req_bin_0 = '\x3d\x00\x04\x00' '\xcc\x01\xe5\x1a' \
-            '\x61\x88\xdd\xe6' '\xd9\x61\x08\x6b'
+        self.req_bin_0 = b'\x3d\x00\x04\x00' b'\xcc\x01\xe5\x1a' \
+            b'\x61\x88\xdd\xe6' b'\xd9\x61\x08\x6b'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ClearArea._request.to_binary, (), self.req_args_0)
+        bin = request.ClearArea._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3062,14 +3070,14 @@
             'width': 46860,
             'src_drawable': 197047820,
             }
-        self.req_bin_0 = '\x3e\x00\x07\x00' '\x0c\xb6\xbe\x0b' \
-            '\xa6\x6a\x81\x5a' '\x46\x2c\x6e\x20' \
-            '\x7d\xc5\x9c\x9d' '\x03\xf3\x20\xd8' \
-            '\x0c\xb7\x01\xb7'
+        self.req_bin_0 = b'\x3e\x00\x07\x00' b'\x0c\xb6\xbe\x0b' \
+            b'\xa6\x6a\x81\x5a' b'\x46\x2c\x6e\x20' \
+            b'\x7d\xc5\x9c\x9d' b'\x03\xf3\x20\xd8' \
+            b'\x0c\xb7\x01\xb7'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CopyArea._request.to_binary, (), self.req_args_0)
+        bin = request.CopyArea._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3101,14 +3109,14 @@
             'width': 12445,
             'src_drawable': 1825271175,
             }
-        self.req_bin_0 = '\x3f\x00\x08\x00' '\x87\x6d\xcb\x6c' \
-            '\x2b\x09\x58\x25' '\x3c\xde\x31\x78' \
-            '\xc3\xc2\x29\xa0' '\x0f\xbc\x31\x9f' \
-            '\x9d\x30\x2c\x24' '\x82\x1b\x3a\x07'
+        self.req_bin_0 = b'\x3f\x00\x08\x00' b'\x87\x6d\xcb\x6c' \
+            b'\x2b\x09\x58\x25' b'\x3c\xde\x31\x78' \
+            b'\xc3\xc2\x29\xa0' b'\x0f\xbc\x31\x9f' \
+            b'\x9d\x30\x2c\x24' b'\x82\x1b\x3a\x07'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CopyPlane._request.to_binary, (), self.req_args_0)
+        bin = request.CopyPlane._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3134,13 +3142,13 @@
             'points': [{'y': -18047, 'x': -19763}, {'y': -5351, 'x': -20174}, {'y': -10573, 'x': -29362}],
             'gc': 1752128743,
             }
-        self.req_bin_0 = '\x40\x00\x06\x00' '\x2b\xdd\x32\x43' \
-            '\xe7\x5c\x6f\x68' '\xcd\xb2\x81\xb9' \
-            '\x32\xb1\x19\xeb' '\x4e\x8d\xb3\xd6'
+        self.req_bin_0 = b'\x40\x00\x06\x00' b'\x2b\xdd\x32\x43' \
+            b'\xe7\x5c\x6f\x68' b'\xcd\xb2\x81\xb9' \
+            b'\x32\xb1\x19\xeb' b'\x4e\x8d\xb3\xd6'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolyPoint._request.to_binary, (), self.req_args_0)
+        bin = request.PolyPoint._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3166,14 +3174,14 @@
             'points': [{'y': -22360, 'x': -25237}, {'y': -21145, 'x': -28948}, {'y': -16928, 'x': -3515}, {'y': -25838, 'x': -12335}, {'y': -31134, 'x': -12944}],
             'gc': 1308624032,
             }
-        self.req_bin_0 = '\x41\x01\x08\x00' '\x3f\xf4\xc1\x50' \
-            '\xa0\x04\x00\x4e' '\x6b\x9d\xa8\xa8' \
-            '\xec\x8e\x67\xad' '\x45\xf2\xe0\xbd' \
-            '\xd1\xcf\x12\x9b' '\x70\xcd\x62\x86'
+        self.req_bin_0 = b'\x41\x01\x08\x00' b'\x3f\xf4\xc1\x50' \
+            b'\xa0\x04\x00\x4e' b'\x6b\x9d\xa8\xa8' \
+            b'\xec\x8e\x67\xad' b'\x45\xf2\xe0\xbd' \
+            b'\xd1\xcf\x12\x9b' b'\x70\xcd\x62\x86'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolyLine._request.to_binary, (), self.req_args_0)
+        bin = request.PolyLine._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3198,13 +3206,13 @@
             'gc': 2022424938,
             'drawable': 158182613,
             }
-        self.req_bin_0 = '\x42\x00\x05\x00' '\xd5\xac\x6d\x09' \
-            '\x6a\xc1\x8b\x78' '\x37\xf7\xa8\xf3' \
-            '\xed\xeb\x08\x97'
+        self.req_bin_0 = b'\x42\x00\x05\x00' b'\xd5\xac\x6d\x09' \
+            b'\x6a\xc1\x8b\x78' b'\x37\xf7\xa8\xf3' \
+            b'\xed\xeb\x08\x97'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolySegment._request.to_binary, (), self.req_args_0)
+        bin = request.PolySegment._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3229,15 +3237,15 @@
             'drawable': 2136753875,
             'rectangles': [{'y': -29358, 'x': -6957, 'height': 19230, 'width': 32377}, {'y': -23694, 'x': -2777, 'height': 48827, 'width': 42548}, {'y': -22773, 'x': -12641, 'height': 9809, 'width': 30955}],
             }
-        self.req_bin_0 = '\x43\x00\x09\x00' '\xd3\x46\x5c\x7f' \
-            '\x93\xd8\xc5\x3d' '\xd3\xe4\x52\x8d' \
-            '\x79\x7e\x1e\x4b' '\x27\xf5\x72\xa3' \
-            '\x34\xa6\xbb\xbe' '\x9f\xce\x0b\xa7' \
-            '\xeb\x78\x51\x26'
+        self.req_bin_0 = b'\x43\x00\x09\x00' b'\xd3\x46\x5c\x7f' \
+            b'\x93\xd8\xc5\x3d' b'\xd3\xe4\x52\x8d' \
+            b'\x79\x7e\x1e\x4b' b'\x27\xf5\x72\xa3' \
+            b'\x34\xa6\xbb\xbe' b'\x9f\xce\x0b\xa7' \
+            b'\xeb\x78\x51\x26'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolyRectangle._request.to_binary, (), self.req_args_0)
+        bin = request.PolyRectangle._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3262,16 +3270,16 @@
             'gc': 956699423,
             'arcs': [{'width': 36714, 'angle1': -22260, 'angle2': -28493, 'y': -394, 'x': -6756, 'height': 63498}, {'width': 31212, 'angle1': -5166, 'angle2': -19039, 'y': -11179, 'x': -20569, 'height': 27113}, {'width': 62033, 'angle1': -18595, 'angle2': -26291, 'y': -8396, 'x': -7987, 'height': 11428}],
             }
-        self.req_bin_0 = '\x44\x00\x0c\x00' '\x96\x82\x2c\x7b' \
-            '\x1f\x13\x06\x39' '\x9c\xe5\x76\xfe' \
-            '\x6a\x8f\x0a\xf8' '\x0c\xa9\xb3\x90' \
-            '\xa7\xaf\x55\xd4' '\xec\x79\xe9\x69' \
-            '\xd2\xeb\xa1\xb5' '\xcd\xe0\x34\xdf' \
-            '\x51\xf2\xa4\x2c' '\x5d\xb7\x4d\x99'
+        self.req_bin_0 = b'\x44\x00\x0c\x00' b'\x96\x82\x2c\x7b' \
+            b'\x1f\x13\x06\x39' b'\x9c\xe5\x76\xfe' \
+            b'\x6a\x8f\x0a\xf8' b'\x0c\xa9\xb3\x90' \
+            b'\xa7\xaf\x55\xd4' b'\xec\x79\xe9\x69' \
+            b'\xd2\xeb\xa1\xb5' b'\xcd\xe0\x34\xdf' \
+            b'\x51\xf2\xa4\x2c' b'\x5d\xb7\x4d\x99'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolyArc._request.to_binary, (), self.req_args_0)
+        bin = request.PolyArc._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3298,14 +3306,14 @@
             'gc': 112110920,
             'shape': 0,
             }
-        self.req_bin_0 = '\x45\x00\x07\x00' '\x96\x94\x65\x1f' \
-            '\x48\xad\xae\x06' '\x00\x01\x00\x00' \
-            '\xd3\xd1\x03\xfd' '\x8d\xf8\x9b\xd5' \
-            '\x2c\xfe\xf2\x8b'
+        self.req_bin_0 = b'\x45\x00\x07\x00' b'\x96\x94\x65\x1f' \
+            b'\x48\xad\xae\x06' b'\x00\x01\x00\x00' \
+            b'\xd3\xd1\x03\xfd' b'\x8d\xf8\x9b\xd5' \
+            b'\x2c\xfe\xf2\x8b'
 
 
     def testPackRequest0(self):
-        bin = apply(request.FillPoly._request.to_binary, (), self.req_args_0)
+        bin = request.FillPoly._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3330,14 +3338,14 @@
             'drawable': 878946804,
             'rectangles': [{'y': -29169, 'x': -18095, 'height': 15301, 'width': 12078}, {'y': -7148, 'x': -18997, 'height': 7501, 'width': 17120}],
             }
-        self.req_bin_0 = '\x46\x00\x07\x00' '\xf4\xa9\x63\x34' \
-            '\x64\x38\xf1\x1b' '\x51\xb9\x0f\x8e' \
-            '\x2e\x2f\xc5\x3b' '\xcb\xb5\x14\xe4' \
-            '\xe0\x42\x4d\x1d'
+        self.req_bin_0 = b'\x46\x00\x07\x00' b'\xf4\xa9\x63\x34' \
+            b'\x64\x38\xf1\x1b' b'\x51\xb9\x0f\x8e' \
+            b'\x2e\x2f\xc5\x3b' b'\xcb\xb5\x14\xe4' \
+            b'\xe0\x42\x4d\x1d'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolyFillRectangle._request.to_binary, (), self.req_args_0)
+        bin = request.PolyFillRectangle._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3362,13 +3370,13 @@
             'gc': 1256983120,
             'arcs': [{'width': 62526, 'angle1': -17496, 'angle2': -20949, 'y': -21843, 'x': -31746, 'height': 59073}],
             }
-        self.req_bin_0 = '\x47\x00\x06\x00' '\x34\xfa\xab\x4c' \
-            '\x50\x0a\xec\x4a' '\xfe\x83\xad\xaa' \
-            '\x3e\xf4\xc1\xe6' '\xa8\xbb\x2b\xae'
+        self.req_bin_0 = b'\x47\x00\x06\x00' b'\x34\xfa\xab\x4c' \
+            b'\x50\x0a\xec\x4a' b'\xfe\x83\xad\xaa' \
+            b'\x3e\xf4\xc1\xe6' b'\xa8\xbb\x2b\xae'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolyFillArc._request.to_binary, (), self.req_args_0)
+        bin = request.PolyFillArc._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3400,15 +3408,15 @@
             'depth': 218,
             'height': 16464,
             }
-        self.req_bin_0 = '\x48\x02\x09\x00' '\x1e\xd0\xc5\x37' \
-            '\x3d\xb4\xbf\x6e' '\x58\x9a\x50\x40' \
-            '\x1b\xdc\xc8\xb6' '\xde\xda\x00\x00' \
-            '\x62\x69\x74\x20' '\x6d\x61\x70\x20' \
-            '\x64\x61\x74\x61'
+        self.req_bin_0 = b'\x48\x02\x09\x00' b'\x1e\xd0\xc5\x37' \
+            b'\x3d\xb4\xbf\x6e' b'\x58\x9a\x50\x40' \
+            b'\x1b\xdc\xc8\xb6' b'\xde\xda\x00\x00' \
+            b'\x62\x69\x74\x20' b'\x6d\x61\x70\x20' \
+            b'\x64\x61\x74\x61'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PutImage._request.to_binary, (), self.req_args_0)
+        bin = request.PutImage._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3437,9 +3445,9 @@
             'plane_mask': 849117586,
             'height': 24480,
             }
-        self.req_bin_0 = '\x49\x01\x05\x00' '\x87\xf9\x81\x16' \
-            '\x3f\x80\x7c\xf5' '\x49\xba\xa0\x5f' \
-            '\x92\x81\x9c\x32'
+        self.req_bin_0 = b'\x49\x01\x05\x00' b'\x87\xf9\x81\x16' \
+            b'\x3f\x80\x7c\xf5' b'\x49\xba\xa0\x5f' \
+            b'\x92\x81\x9c\x32'
 
         self.reply_args_0 = {
             'depth': 249,
@@ -3447,18 +3455,18 @@
             'visual': 141686402,
             'sequence_number': 47197,
             }
-        self.reply_bin_0 = '\x01\xf9\x5d\xb8' '\x07\x00\x00\x00' \
-            '\x82\xf6\x71\x08' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x74\x68\x69\x73' '\x20\x69\x73\x20' \
-            '\x72\x65\x61\x6c' '\x20\x6c\x79\x20' \
-            '\x69\x6d\x61\x67' '\x20\x65\x20\x62' \
-            '\x2d\x6d\x61\x70'
+        self.reply_bin_0 = b'\x01\xf9\x5d\xb8' b'\x07\x00\x00\x00' \
+            b'\x82\xf6\x71\x08' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x74\x68\x69\x73' b'\x20\x69\x73\x20' \
+            b'\x72\x65\x61\x6c' b'\x20\x6c\x79\x20' \
+            b'\x69\x6d\x61\x67' b'\x20\x65\x20\x62' \
+            b'\x2d\x6d\x61\x70'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetImage._request.to_binary, (), self.req_args_0)
+        bin = request.GetImage._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3476,7 +3484,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetImage._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetImage._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -3503,14 +3511,14 @@
             'gc': 1348241590,
             'x': -27139,
             }
-        self.req_bin_0 = '\x4a\x00\x08\x00' '\x18\x69\x7f\x67' \
-            '\xb6\x88\x5c\x50' '\xfd\x95\x84\xe4' \
-            '\x03\x02\x7a\x6f' '\x6f\xff\x01\x02' \
-            '\x03\x04\x02\x00' '\x69\x65\x00\x00'
+        self.req_bin_0 = b'\x4a\x00\x08\x00' b'\x18\x69\x7f\x67' \
+            b'\xb6\x88\x5c\x50' b'\xfd\x95\x84\xe4' \
+            b'\x03\x02\x7a\x6f' b'\x6f\xff\x01\x02' \
+            b'\x03\x04\x02\x00' b'\x69\x65\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolyText8._request.to_binary, (), self.req_args_0)
+        bin = request.PolyText8._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3537,14 +3545,14 @@
             'gc': 327278878,
             'x': -31319,
             }
-        self.req_bin_0 = '\x4b\x00\x07\x00' '\x50\x96\x80\x63' \
-            '\x1e\xe1\x81\x13' '\xa9\x85\xd9\xd6' \
-            '\x02\x02\x10\x23' '\x00\x12\xff\x01' \
-            '\x02\x03\x04\x00'
+        self.req_bin_0 = b'\x4b\x00\x07\x00' b'\x50\x96\x80\x63' \
+            b'\x1e\xe1\x81\x13' b'\xa9\x85\xd9\xd6' \
+            b'\x02\x02\x10\x23' b'\x00\x12\xff\x01' \
+            b'\x02\x03\x04\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.PolyText16._request.to_binary, (), self.req_args_0)
+        bin = request.PolyText16._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3571,13 +3579,13 @@
             'gc': 581816261,
             'string': 'showme',
             }
-        self.req_bin_0 = '\x4c\x06\x06\x00' '\x50\xb6\x0d\x7f' \
-            '\xc5\xcf\xad\x22' '\xd3\xc4\x71\xf1' \
-            '\x73\x68\x6f\x77' '\x6d\x65\x00\x00'
+        self.req_bin_0 = b'\x4c\x06\x06\x00' b'\x50\xb6\x0d\x7f' \
+            b'\xc5\xcf\xad\x22' b'\xd3\xc4\x71\xf1' \
+            b'\x73\x68\x6f\x77' b'\x6d\x65\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ImageText8._request.to_binary, (), self.req_args_0)
+        bin = request.ImageText8._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3604,14 +3612,14 @@
             'gc': 145495998,
             'string': (115, 104, 111, 119, 109, 111, 114, 101),
             }
-        self.req_bin_0 = '\x4d\x08\x08\x00' '\x96\xa8\xff\x55' \
-            '\xbe\x17\xac\x08' '\xe1\xf4\xce\xfb' \
-            '\x00\x73\x00\x68' '\x00\x6f\x00\x77' \
-            '\x00\x6d\x00\x6f' '\x00\x72\x00\x65'
+        self.req_bin_0 = b'\x4d\x08\x08\x00' b'\x96\xa8\xff\x55' \
+            b'\xbe\x17\xac\x08' b'\xe1\xf4\xce\xfb' \
+            b'\x00\x73\x00\x68' b'\x00\x6f\x00\x77' \
+            b'\x00\x6d\x00\x6f' b'\x00\x72\x00\x65'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ImageText16._request.to_binary, (), self.req_args_0)
+        bin = request.ImageText16._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3637,12 +3645,12 @@
             'visual': 1165319270,
             'mid': 1982619692,
             }
-        self.req_bin_0 = '\x4e\x00\x04\x00' '\x2c\x60\x2c\x76' \
-            '\xc5\x34\xa3\x52' '\x66\x5c\x75\x45'
+        self.req_bin_0 = b'\x4e\x00\x04\x00' b'\x2c\x60\x2c\x76' \
+            b'\xc5\x34\xa3\x52' b'\x66\x5c\x75\x45'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CreateColormap._request.to_binary, (), self.req_args_0)
+        bin = request.CreateColormap._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3665,11 +3673,11 @@
         self.req_args_0 = {
             'cmap': 1948229362,
             }
-        self.req_bin_0 = '\x4f\x00\x02\x00' '\xf2\x9e\x1f\x74'
+        self.req_bin_0 = b'\x4f\x00\x02\x00' b'\xf2\x9e\x1f\x74'
 
 
     def testPackRequest0(self):
-        bin = apply(request.FreeColormap._request.to_binary, (), self.req_args_0)
+        bin = request.FreeColormap._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3693,12 +3701,12 @@
             'src_cmap': 836376231,
             'mid': 1781544437,
             }
-        self.req_bin_0 = '\x50\x00\x03\x00' '\xf5\x35\x30\x6a' \
-            '\xa7\x16\xda\x31'
+        self.req_bin_0 = b'\x50\x00\x03\x00' b'\xf5\x35\x30\x6a' \
+            b'\xa7\x16\xda\x31'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CopyColormapAndFree._request.to_binary, (), self.req_args_0)
+        bin = request.CopyColormapAndFree._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3721,11 +3729,11 @@
         self.req_args_0 = {
             'cmap': 1065317214,
             }
-        self.req_bin_0 = '\x51\x00\x02\x00' '\x5e\x73\x7f\x3f'
+        self.req_bin_0 = b'\x51\x00\x02\x00' b'\x5e\x73\x7f\x3f'
 
 
     def testPackRequest0(self):
-        bin = apply(request.InstallColormap._request.to_binary, (), self.req_args_0)
+        bin = request.InstallColormap._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3748,11 +3756,11 @@
         self.req_args_0 = {
             'cmap': 1636916558,
             }
-        self.req_bin_0 = '\x52\x00\x02\x00' '\x4e\x5d\x91\x61'
+        self.req_bin_0 = b'\x52\x00\x02\x00' b'\x4e\x5d\x91\x61'
 
 
     def testPackRequest0(self):
-        bin = apply(request.UninstallColormap._request.to_binary, (), self.req_args_0)
+        bin = request.UninstallColormap._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3775,21 +3783,21 @@
         self.req_args_0 = {
             'window': 198767900,
             }
-        self.req_bin_0 = '\x53\x00\x02\x00' '\x1c\xf5\xd8\x0b'
+        self.req_bin_0 = b'\x53\x00\x02\x00' b'\x1c\xf5\xd8\x0b'
 
         self.reply_args_0 = {
             'cmaps': [6854304, 441133660],
             'sequence_number': 56438,
             }
-        self.reply_bin_0 = '\x01\x00\x76\xdc' '\x02\x00\x00\x00' \
-            '\x02\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\xa0\x96\x68\x00' '\x5c\x2a\x4b\x1a'
+        self.reply_bin_0 = b'\x01\x00\x76\xdc' b'\x02\x00\x00\x00' \
+            b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\xa0\x96\x68\x00' b'\x5c\x2a\x4b\x1a'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ListInstalledColormaps._request.to_binary, (), self.req_args_0)
+        bin = request.ListInstalledColormaps._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3807,7 +3815,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.ListInstalledColormaps._reply.to_binary, (), self.reply_args_0)
+        bin = request.ListInstalledColormaps._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -3833,8 +3841,8 @@
             'green': 61383,
             'red': 8870,
             }
-        self.req_bin_0 = '\x54\x00\x04\x00' '\xdf\x36\xda\x69' \
-            '\xa6\x22\xc7\xef' '\x24\xe2\x00\x00'
+        self.req_bin_0 = b'\x54\x00\x04\x00' b'\xdf\x36\xda\x69' \
+            b'\xa6\x22\xc7\xef' b'\x24\xe2\x00\x00'
 
         self.reply_args_0 = {
             'blue': 22111,
@@ -3843,14 +3851,14 @@
             'sequence_number': 52666,
             'pixel': 1186287049,
             }
-        self.reply_bin_0 = '\x01\x00\xba\xcd' '\x00\x00\x00\x00' \
-            '\x61\xd4\x90\x6b' '\x5f\x56\x00\x00' \
-            '\xc9\x4d\xb5\x46' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\xba\xcd' b'\x00\x00\x00\x00' \
+            b'\x61\xd4\x90\x6b' b'\x5f\x56\x00\x00' \
+            b'\xc9\x4d\xb5\x46' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.AllocColor._request.to_binary, (), self.req_args_0)
+        bin = request.AllocColor._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3868,7 +3876,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.AllocColor._reply.to_binary, (), self.reply_args_0)
+        bin = request.AllocColor._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -3892,9 +3900,9 @@
             'cmap': 695059054,
             'name': 'octarin',
             }
-        self.req_bin_0 = '\x55\x00\x05\x00' '\x6e\xc2\x6d\x29' \
-            '\x07\x00\x00\x00' '\x6f\x63\x74\x61' \
-            '\x72\x69\x6e\x00'
+        self.req_bin_0 = b'\x55\x00\x05\x00' b'\x6e\xc2\x6d\x29' \
+            b'\x07\x00\x00\x00' b'\x6f\x63\x74\x61' \
+            b'\x72\x69\x6e\x00'
 
         self.reply_args_0 = {
             'exact_red': 45174,
@@ -3906,14 +3914,14 @@
             'sequence_number': 38835,
             'pixel': 580415589,
             }
-        self.reply_bin_0 = '\x01\x00\xb3\x97' '\x00\x00\x00\x00' \
-            '\x65\x70\x98\x22' '\x76\xb0\xca\xaf' \
-            '\xa3\xda\x51\xec' '\x6b\xbb\xd6\x54' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\xb3\x97' b'\x00\x00\x00\x00' \
+            b'\x65\x70\x98\x22' b'\x76\xb0\xca\xaf' \
+            b'\xa3\xda\x51\xec' b'\x6b\xbb\xd6\x54' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.AllocNamedColor._request.to_binary, (), self.req_args_0)
+        bin = request.AllocNamedColor._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -3931,7 +3939,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.AllocNamedColor._reply.to_binary, (), self.reply_args_0)
+        bin = request.AllocNamedColor._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -3957,42 +3965,42 @@
             'colors': 16292,
             'planes': 14978,
             }
-        self.req_bin_0 = '\x56\x01\x03\x00' '\xb5\xe9\x73\x7b' \
-            '\xa4\x3f\x82\x3a'
+        self.req_bin_0 = b'\x56\x01\x03\x00' b'\xb5\xe9\x73\x7b' \
+            b'\xa4\x3f\x82\x3a'
 
         self.reply_args_0 = {
             'pixels': [1664874569, 198876857, 135035151, 1499807858, 600240169, 1403510863, 757170725, 929995606, 155550883, 642439566, 971734621, 1359474267, 609593319, 669993327, 1837906914, 1355959290, 835285748],
             'masks': [50898278, 362272940, 1106373487],
             'sequence_number': 57786,
             }
-        self.reply_bin_0 = '\x01\x00\xba\xe1' '\x14\x00\x00\x00' \
-            '\x11\x00\x03\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x49\xf8\x3b\x63' '\xb9\x9e\xda\x0b' \
-            '\x0f\x79\x0c\x08' '\x72\x40\x65\x59' \
-            '\x29\xf0\xc6\x23' '\x4f\xe0\xa7\x53' \
-            '\x25\x82\x21\x2d' '\x56\x9b\x6e\x37' \
-            '\xa3\x84\x45\x09' '\x8e\xd9\x4a\x26' \
-            '\x5d\x7e\xeb\x39' '\x5b\xee\x07\x51' \
-            '\xe7\xa7\x55\x24' '\x6f\x49\xef\x27' \
-            '\xe2\x3b\x8c\x6d' '\xfa\x4b\xd2\x50' \
-            '\xf4\x72\xc9\x31' '\x66\xa5\x08\x03' \
-            '\xac\xd8\x97\x15' '\x6f\xeb\xf1\x41'
+        self.reply_bin_0 = b'\x01\x00\xba\xe1' b'\x14\x00\x00\x00' \
+            b'\x11\x00\x03\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x49\xf8\x3b\x63' b'\xb9\x9e\xda\x0b' \
+            b'\x0f\x79\x0c\x08' b'\x72\x40\x65\x59' \
+            b'\x29\xf0\xc6\x23' b'\x4f\xe0\xa7\x53' \
+            b'\x25\x82\x21\x2d' b'\x56\x9b\x6e\x37' \
+            b'\xa3\x84\x45\x09' b'\x8e\xd9\x4a\x26' \
+            b'\x5d\x7e\xeb\x39' b'\x5b\xee\x07\x51' \
+            b'\xe7\xa7\x55\x24' b'\x6f\x49\xef\x27' \
+            b'\xe2\x3b\x8c\x6d' b'\xfa\x4b\xd2\x50' \
+            b'\xf4\x72\xc9\x31' b'\x66\xa5\x08\x03' \
+            b'\xac\xd8\x97\x15' b'\x6f\xeb\xf1\x41'
 
         self.reply_args_1 = {
             'pixels': [],
             'masks': [],
             'sequence_number': 49324,
             }
-        self.reply_bin_1 = '\x01\x00\xac\xc0' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_1 = b'\x01\x00\xac\xc0' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.AllocColorCells._request.to_binary, (), self.req_args_0)
+        bin = request.AllocColorCells._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4010,7 +4018,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.AllocColorCells._reply.to_binary, (), self.reply_args_0)
+        bin = request.AllocColorCells._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4028,7 +4036,7 @@
             raise AssertionError(args)
 
     def testPackReply1(self):
-        bin = apply(request.AllocColorCells._reply.to_binary, (), self.reply_args_1)
+        bin = request.AllocColorCells._reply.to_binary(*(), **self.reply_args_1)
         try:
             assert bin == self.reply_bin_1
         except AssertionError:
@@ -4056,8 +4064,8 @@
             'contiguous': 1,
             'red': 37700,
             }
-        self.req_bin_0 = '\x57\x01\x04\x00' '\xd7\xef\xa3\x7d' \
-            '\x7f\x2e\x44\x93' '\xfe\x83\xc1\x85'
+        self.req_bin_0 = b'\x57\x01\x04\x00' b'\xd7\xef\xa3\x7d' \
+            b'\x7f\x2e\x44\x93' b'\xfe\x83\xc1\x85'
 
         self.reply_args_0 = {
             'red_mask': 931105404,
@@ -4066,16 +4074,16 @@
             'sequence_number': 17565,
             'green_mask': 1072565720,
             }
-        self.reply_bin_0 = '\x01\x00\x9d\x44' '\x04\x00\x00\x00' \
-            '\x04\x00\x00\x00' '\x7c\x8a\x7f\x37' \
-            '\xd8\x0d\xee\x3f' '\x22\x6f\x22\x34' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\xc1\x6a\xe4\x63' '\x4c\x82\xa2\x4a' \
-            '\x37\x09\x41\x02' '\x4a\xdf\xc6\x57'
+        self.reply_bin_0 = b'\x01\x00\x9d\x44' b'\x04\x00\x00\x00' \
+            b'\x04\x00\x00\x00' b'\x7c\x8a\x7f\x37' \
+            b'\xd8\x0d\xee\x3f' b'\x22\x6f\x22\x34' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\xc1\x6a\xe4\x63' b'\x4c\x82\xa2\x4a' \
+            b'\x37\x09\x41\x02' b'\x4a\xdf\xc6\x57'
 
 
     def testPackRequest0(self):
-        bin = apply(request.AllocColorPlanes._request.to_binary, (), self.req_args_0)
+        bin = request.AllocColorPlanes._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4093,7 +4101,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.AllocColorPlanes._reply.to_binary, (), self.reply_args_0)
+        bin = request.AllocColorPlanes._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4118,20 +4126,20 @@
             'plane_mask': 1074378407,
             'pixels': [2014216051, 1664038241, 1220941033, 1378294408, 197757808, 793595544, 1289781247, 713684847, 1724469541, 1432124373, 1426727603, 1787792301, 406458839, 1918513211, 441394489, 988895943, 146997744],
             }
-        self.req_bin_0 = '\x58\x00\x14\x00' '\x1e\xdf\xf2\x01' \
-            '\xa7\xb6\x09\x40' '\x73\x7f\x0e\x78' \
-            '\x61\x35\x2f\x63' '\xe9\x14\xc6\x48' \
-            '\x88\x1a\x27\x52' '\x70\x8b\xc9\x0b' \
-            '\x98\x4e\x4d\x2f' '\xff\x7f\xe0\x4c' \
-            '\x6f\xf7\x89\x2a' '\x25\x51\xc9\x66' \
-            '\xd5\x7b\x5c\x55' '\xb3\x22\x0a\x55' \
-            '\xad\x8b\x8f\x6a' '\xd7\x11\x3a\x18' \
-            '\x3b\x30\x5a\x72' '\x39\x25\x4f\x1a' \
-            '\xc7\x5a\xf1\x3a' '\xf0\x01\xc3\x08'
+        self.req_bin_0 = b'\x58\x00\x14\x00' b'\x1e\xdf\xf2\x01' \
+            b'\xa7\xb6\x09\x40' b'\x73\x7f\x0e\x78' \
+            b'\x61\x35\x2f\x63' b'\xe9\x14\xc6\x48' \
+            b'\x88\x1a\x27\x52' b'\x70\x8b\xc9\x0b' \
+            b'\x98\x4e\x4d\x2f' b'\xff\x7f\xe0\x4c' \
+            b'\x6f\xf7\x89\x2a' b'\x25\x51\xc9\x66' \
+            b'\xd5\x7b\x5c\x55' b'\xb3\x22\x0a\x55' \
+            b'\xad\x8b\x8f\x6a' b'\xd7\x11\x3a\x18' \
+            b'\x3b\x30\x5a\x72' b'\x39\x25\x4f\x1a' \
+            b'\xc7\x5a\xf1\x3a' b'\xf0\x01\xc3\x08'
 
 
     def testPackRequest0(self):
-        bin = apply(request.FreeColors._request.to_binary, (), self.req_args_0)
+        bin = request.FreeColors._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4155,17 +4163,17 @@
             'items': [{'blue': 3577, 'flags': 221, 'green': 15650, 'pixel': 330879354, 'red': 30294}, {'blue': 18226, 'flags': 219, 'green': 45614, 'pixel': 302874221, 'red': 54265}, {'blue': 32215, 'flags': 160, 'green': 48737, 'pixel': 1699694808, 'red': 60115}, {'blue': 28524, 'flags': 209, 'green': 37615, 'pixel': 710550693, 'red': 50488}],
             'cmap': 1791140577,
             }
-        self.req_bin_0 = '\x59\x00\x0e\x00' '\xe1\xa2\xc2\x6a' \
-            '\x7a\xd1\xb8\x13' '\x56\x76\x22\x3d' \
-            '\xf9\x0d\xdd\x00' '\x6d\x7e\x0d\x12' \
-            '\xf9\xd3\x2e\xb2' '\x32\x47\xdb\x00' \
-            '\xd8\x48\x4f\x65' '\xd3\xea\x61\xbe' \
-            '\xd7\x7d\xa0\x00' '\xa5\x24\x5a\x2a' \
-            '\x38\xc5\xef\x92' '\x6c\x6f\xd1\x00'
+        self.req_bin_0 = b'\x59\x00\x0e\x00' b'\xe1\xa2\xc2\x6a' \
+            b'\x7a\xd1\xb8\x13' b'\x56\x76\x22\x3d' \
+            b'\xf9\x0d\xdd\x00' b'\x6d\x7e\x0d\x12' \
+            b'\xf9\xd3\x2e\xb2' b'\x32\x47\xdb\x00' \
+            b'\xd8\x48\x4f\x65' b'\xd3\xea\x61\xbe' \
+            b'\xd7\x7d\xa0\x00' b'\xa5\x24\x5a\x2a' \
+            b'\x38\xc5\xef\x92' b'\x6c\x6f\xd1\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.StoreColors._request.to_binary, (), self.req_args_0)
+        bin = request.StoreColors._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4191,13 +4199,13 @@
             'name': 'blue',
             'pixel': 413175613,
             }
-        self.req_bin_0 = '\x5a\xa9\x05\x00' '\xf4\xd5\xd0\x33' \
-            '\x3d\x8f\xa0\x18' '\x04\x00\x00\x00' \
-            '\x62\x6c\x75\x65'
+        self.req_bin_0 = b'\x5a\xa9\x05\x00' b'\xf4\xd5\xd0\x33' \
+            b'\x3d\x8f\xa0\x18' b'\x04\x00\x00\x00' \
+            b'\x62\x6c\x75\x65'
 
 
     def testPackRequest0(self):
-        bin = apply(request.StoreNamedColor._request.to_binary, (), self.req_args_0)
+        bin = request.StoreNamedColor._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4221,35 +4229,35 @@
             'cmap': 1750052450,
             'pixels': [1673396539, 1897675292, 1453845591, 816818886, 897340342, 1782049962, 796231465, 722380604],
             }
-        self.req_bin_0 = '\x5b\x00\x0a\x00' '\x62\xae\x4f\x68' \
-            '\x3b\x01\xbe\x63' '\x1c\x3a\x1c\x71' \
-            '\x57\xec\xa7\x56' '\xc6\xaa\xaf\x30' \
-            '\xb6\x53\x7c\x35' '\xaa\xec\x37\x6a' \
-            '\x29\x87\x75\x2f' '\x3c\xa7\x0e\x2b'
+        self.req_bin_0 = b'\x5b\x00\x0a\x00' b'\x62\xae\x4f\x68' \
+            b'\x3b\x01\xbe\x63' b'\x1c\x3a\x1c\x71' \
+            b'\x57\xec\xa7\x56' b'\xc6\xaa\xaf\x30' \
+            b'\xb6\x53\x7c\x35' b'\xaa\xec\x37\x6a' \
+            b'\x29\x87\x75\x2f' b'\x3c\xa7\x0e\x2b'
 
         self.reply_args_0 = {
             'colors': [{'blue': 63820, 'green': 60107, 'red': 62261}, {'blue': 54480, 'green': 48839, 'red': 10033}, {'blue': 31765, 'green': 31737, 'red': 43117}, {'blue': 50953, 'green': 52009, 'red': 14234}, {'blue': 55150, 'green': 30330, 'red': 55956}],
             'sequence_number': 10895,
             }
-        self.reply_bin_0 = '\x01\x00\x8f\x2a' '\x0a\x00\x00\x00' \
-            '\x05\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x35\xf3\xcb\xea' '\x4c\xf9\x00\x00' \
-            '\x31\x27\xc7\xbe' '\xd0\xd4\x00\x00' \
-            '\x6d\xa8\xf9\x7b' '\x15\x7c\x00\x00' \
-            '\x9a\x37\x29\xcb' '\x09\xc7\x00\x00' \
-            '\x94\xda\x7a\x76' '\x6e\xd7\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\x8f\x2a' b'\x0a\x00\x00\x00' \
+            b'\x05\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x35\xf3\xcb\xea' b'\x4c\xf9\x00\x00' \
+            b'\x31\x27\xc7\xbe' b'\xd0\xd4\x00\x00' \
+            b'\x6d\xa8\xf9\x7b' b'\x15\x7c\x00\x00' \
+            b'\x9a\x37\x29\xcb' b'\x09\xc7\x00\x00' \
+            b'\x94\xda\x7a\x76' b'\x6e\xd7\x00\x00'
 
         self.req_args_1 = {
             'cmap': 340337174,
             'pixels': [],
             }
-        self.req_bin_1 = '\x5b\x00\x02\x00' '\x16\x22\x49\x14'
+        self.req_bin_1 = b'\x5b\x00\x02\x00' b'\x16\x22\x49\x14'
 
 
     def testPackRequest0(self):
-        bin = apply(request.QueryColors._request.to_binary, (), self.req_args_0)
+        bin = request.QueryColors._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4267,7 +4275,7 @@
             raise AssertionError(args)
 
     def testPackRequest1(self):
-        bin = apply(request.QueryColors._request.to_binary, (), self.req_args_1)
+        bin = request.QueryColors._request.to_binary(*(), **self.req_args_1)
         try:
             assert bin == self.req_bin_1
         except AssertionError:
@@ -4285,7 +4293,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.QueryColors._reply.to_binary, (), self.reply_args_0)
+        bin = request.QueryColors._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4309,9 +4317,9 @@
             'cmap': 2120409969,
             'name': 'octarin',
             }
-        self.req_bin_0 = '\x5c\x00\x05\x00' '\x71\xe3\x62\x7e' \
-            '\x07\x00\x00\x00' '\x6f\x63\x74\x61' \
-            '\x72\x69\x6e\x00'
+        self.req_bin_0 = b'\x5c\x00\x05\x00' b'\x71\xe3\x62\x7e' \
+            b'\x07\x00\x00\x00' b'\x6f\x63\x74\x61' \
+            b'\x72\x69\x6e\x00'
 
         self.reply_args_0 = {
             'exact_red': 63730,
@@ -4322,14 +4330,14 @@
             'screen_red': 26587,
             'sequence_number': 2933,
             }
-        self.reply_bin_0 = '\x01\x00\x75\x0b' '\x00\x00\x00\x00' \
-            '\xf2\xf8\x50\x5f' '\x65\x6b\xdb\x67' \
-            '\x06\x3e\xfb\x24' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\x75\x0b' b'\x00\x00\x00\x00' \
+            b'\xf2\xf8\x50\x5f' b'\x65\x6b\xdb\x67' \
+            b'\x06\x3e\xfb\x24' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.LookupColor._request.to_binary, (), self.req_args_0)
+        bin = request.LookupColor._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4347,7 +4355,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.LookupColor._reply.to_binary, (), self.reply_args_0)
+        bin = request.LookupColor._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4380,14 +4388,14 @@
             'x': 731,
             'back_red': 30886,
             }
-        self.req_bin_0 = '\x5d\x00\x08\x00' '\xa6\x29\xd3\x52' \
-            '\x5d\x7b\xd1\x7a' '\xf2\xa8\xf2\x57' \
-            '\x9f\xa7\x3b\x7d' '\xdd\xb1\xa6\x78' \
-            '\x15\x24\x39\x1d' '\xdb\x02\xa7\x7c'
+        self.req_bin_0 = b'\x5d\x00\x08\x00' b'\xa6\x29\xd3\x52' \
+            b'\x5d\x7b\xd1\x7a' b'\xf2\xa8\xf2\x57' \
+            b'\x9f\xa7\x3b\x7d' b'\xdd\xb1\xa6\x78' \
+            b'\x15\x24\x39\x1d' b'\xdb\x02\xa7\x7c'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CreateCursor._request.to_binary, (), self.req_args_0)
+        bin = request.CreateCursor._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4420,14 +4428,14 @@
             'source_char': 50271,
             'back_red': 13590,
             }
-        self.req_bin_0 = '\x5e\x00\x08\x00' '\x31\xe7\xc1\x6d' \
-            '\x2a\x85\x48\x01' '\x50\x9a\x89\x10' \
-            '\x5f\xc4\xdc\x4a' '\xeb\x23\xfc\xc7' \
-            '\xb7\x62\x16\x35' '\xed\xd7\xfb\x1c'
+        self.req_bin_0 = b'\x5e\x00\x08\x00' b'\x31\xe7\xc1\x6d' \
+            b'\x2a\x85\x48\x01' b'\x50\x9a\x89\x10' \
+            b'\x5f\xc4\xdc\x4a' b'\xeb\x23\xfc\xc7' \
+            b'\xb7\x62\x16\x35' b'\xed\xd7\xfb\x1c'
 
 
     def testPackRequest0(self):
-        bin = apply(request.CreateGlyphCursor._request.to_binary, (), self.req_args_0)
+        bin = request.CreateGlyphCursor._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4450,11 +4458,11 @@
         self.req_args_0 = {
             'cursor': 830435200,
             }
-        self.req_bin_0 = '\x5f\x00\x02\x00' '\x80\x6f\x7f\x31'
+        self.req_bin_0 = b'\x5f\x00\x02\x00' b'\x80\x6f\x7f\x31'
 
 
     def testPackRequest0(self):
-        bin = apply(request.FreeCursor._request.to_binary, (), self.req_args_0)
+        bin = request.FreeCursor._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4483,13 +4491,13 @@
             'fore_green': 39148,
             'fore_red': 48154,
             }
-        self.req_bin_0 = '\x60\x00\x05\x00' '\xc3\xa3\xe5\x23' \
-            '\x1a\xbc\xec\x98' '\x24\xfa\x82\x17' \
-            '\x80\xbf\x4f\x3c'
+        self.req_bin_0 = b'\x60\x00\x05\x00' b'\xc3\xa3\xe5\x23' \
+            b'\x1a\xbc\xec\x98' b'\x24\xfa\x82\x17' \
+            b'\x80\xbf\x4f\x3c'
 
 
     def testPackRequest0(self):
-        bin = apply(request.RecolorCursor._request.to_binary, (), self.req_args_0)
+        bin = request.RecolorCursor._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4515,22 +4523,22 @@
             'drawable': 1606665099,
             'height': 4701,
             }
-        self.req_bin_0 = '\x61\x01\x03\x00' '\x8b\xc3\xc3\x5f' \
-            '\x60\xce\x5d\x12'
+        self.req_bin_0 = b'\x61\x01\x03\x00' b'\x8b\xc3\xc3\x5f' \
+            b'\x60\xce\x5d\x12'
 
         self.reply_args_0 = {
             'width': 33709,
             'sequence_number': 43788,
             'height': 12826,
             }
-        self.reply_bin_0 = '\x01\x00\x0c\xab' '\x00\x00\x00\x00' \
-            '\xad\x83\x1a\x32' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\x0c\xab' b'\x00\x00\x00\x00' \
+            b'\xad\x83\x1a\x32' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.QueryBestSize._request.to_binary, (), self.req_args_0)
+        bin = request.QueryBestSize._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4548,7 +4556,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.QueryBestSize._reply.to_binary, (), self.reply_args_0)
+        bin = request.QueryBestSize._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4571,8 +4579,8 @@
         self.req_args_0 = {
             'name': 'XTRA',
             }
-        self.req_bin_0 = '\x62\x00\x03\x00' '\x04\x00\x00\x00' \
-            '\x58\x54\x52\x41'
+        self.req_bin_0 = b'\x62\x00\x03\x00' b'\x04\x00\x00\x00' \
+            b'\x58\x54\x52\x41'
 
         self.reply_args_0 = {
             'first_event': 163,
@@ -4581,14 +4589,14 @@
             'present': 1,
             'sequence_number': 3124,
             }
-        self.reply_bin_0 = '\x01\x00\x34\x0c' '\x00\x00\x00\x00' \
-            '\x01\xd7\xa3\xa6' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\x34\x0c' b'\x00\x00\x00\x00' \
+            b'\x01\xd7\xa3\xa6' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.QueryExtension._request.to_binary, (), self.req_args_0)
+        bin = request.QueryExtension._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4606,7 +4614,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.QueryExtension._reply.to_binary, (), self.reply_args_0)
+        bin = request.QueryExtension._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4628,22 +4636,22 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x63\x00\x01\x00'
+        self.req_bin_0 = b'\x63\x00\x01\x00'
 
         self.reply_args_0 = {
             'names': ['XTRA', 'XTRA-II'],
             'sequence_number': 21122,
             }
-        self.reply_bin_0 = '\x01\x02\x82\x52' '\x04\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x04\x58\x54\x52' '\x41\x07\x58\x54' \
-            '\x52\x41\x2d\x49' '\x49\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x02\x82\x52' b'\x04\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x04\x58\x54\x52' b'\x41\x07\x58\x54' \
+            b'\x52\x41\x2d\x49' b'\x49\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ListExtensions._request.to_binary, (), self.req_args_0)
+        bin = request.ListExtensions._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4661,7 +4669,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.ListExtensions._reply.to_binary, (), self.reply_args_0)
+        bin = request.ListExtensions._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4685,41 +4693,41 @@
             'first_keycode': 131,
             'keysyms': [[1479273593, 495399194, 1752874714], [183124138, 826800766, 542058728], [519501686, 1358630902, 1051542205], [1363902850, 52079613, 1721268402], [2124568309, 323328202, 1426344655], [1775218167, 1821828429, 1704892958], [1784543283, 783698836, 1882907069], [1165130550, 1276086917, 957090966], [1623553701, 77158667, 420399405], [790514637, 1104383431, 1645303152], [879499287, 349457843, 1313813953], [367336866, 1207824094, 514125338], [767413913, 135340640, 756292967], [475442692, 2076098223, 1252936842], [964050497, 2006979633, 948353974], [1923834215, 1061136894, 1319606154], [1186538913, 1770176901, 715354628], [1470481551, 403222608, 252019996], [260033548, 1553379907, 1096456683], [2027881549, 1992616114, 382810564]],
             }
-        self.req_bin_0 = '\x64\x14\x3e\x00' '\x83\x03\x00\x00' \
-            '\x79\xec\x2b\x58' '\x1a\x31\x87\x1d' \
-            '\xda\xbe\x7a\x68' '\xaa\x40\xea\x0a' \
-            '\x7e\xfa\x47\x31' '\xe8\x28\x4f\x20' \
-            '\x76\xf7\xf6\x1e' '\xf6\x0f\xfb\x50' \
-            '\xbd\x42\xad\x3e' '\x82\x81\x4b\x51' \
-            '\xfd\xab\x1a\x03' '\xb2\x78\x98\x66' \
-            '\xf5\x56\xa2\x7e' '\xca\x98\x45\x13' \
-            '\xcf\x4a\x04\x55' '\xf7\xad\xcf\x69' \
-            '\x4d\xe5\x96\x6c' '\x1e\x9a\x9e\x65' \
-            '\x33\xf8\x5d\x6a' '\x94\x4b\xb6\x2e' \
-            '\xbd\xe1\x3a\x70' '\x36\x7b\x72\x45' \
-            '\x85\x8a\x0f\x4c' '\x96\x0c\x0c\x39' \
-            '\xa5\x76\xc5\x60' '\x0b\x59\x99\x04' \
-            '\x2d\xc9\x0e\x19' '\xcd\x4b\x1e\x2f' \
-            '\xc7\x8d\xd3\x41' '\x70\x55\x11\x62' \
-            '\x17\x18\x6c\x34' '\xb3\x4d\xd4\x14' \
-            '\xc1\x35\x4f\x4e' '\xa2\x1d\xe5\x15' \
-            '\xde\xee\xfd\x47' '\x1a\xee\xa4\x1e' \
-            '\x99\xce\xbd\x2d' '\x60\x22\x11\x08' \
-            '\x67\x1d\x14\x2d' '\x04\xae\x56\x1c' \
-            '\xaf\xbe\xbe\x7b' '\x8a\x4c\xae\x4a' \
-            '\x41\x3e\x76\x39' '\x31\x14\xa0\x77' \
-            '\xb6\xbb\x86\x38' '\x67\x61\xab\x72' \
-            '\xfe\xa9\x3f\x3f' '\x8a\x97\xa7\x4e' \
-            '\xa1\x25\xb9\x46' '\x85\xc1\x82\x69' \
-            '\x04\x72\xa3\x2a' '\x8f\xc4\xa5\x57' \
-            '\x50\xb0\x08\x18' '\x1c\x85\x05\x0f' \
-            '\x0c\xcc\x7f\x0f' '\x43\xb2\x96\x5c' \
-            '\xeb\x99\x5a\x41' '\x4d\x04\xdf\x78' \
-            '\xb2\xe8\xc4\x76' '\xc4\x39\xd1\x16'
+        self.req_bin_0 = b'\x64\x14\x3e\x00' b'\x83\x03\x00\x00' \
+            b'\x79\xec\x2b\x58' b'\x1a\x31\x87\x1d' \
+            b'\xda\xbe\x7a\x68' b'\xaa\x40\xea\x0a' \
+            b'\x7e\xfa\x47\x31' b'\xe8\x28\x4f\x20' \
+            b'\x76\xf7\xf6\x1e' b'\xf6\x0f\xfb\x50' \
+            b'\xbd\x42\xad\x3e' b'\x82\x81\x4b\x51' \
+            b'\xfd\xab\x1a\x03' b'\xb2\x78\x98\x66' \
+            b'\xf5\x56\xa2\x7e' b'\xca\x98\x45\x13' \
+            b'\xcf\x4a\x04\x55' b'\xf7\xad\xcf\x69' \
+            b'\x4d\xe5\x96\x6c' b'\x1e\x9a\x9e\x65' \
+            b'\x33\xf8\x5d\x6a' b'\x94\x4b\xb6\x2e' \
+            b'\xbd\xe1\x3a\x70' b'\x36\x7b\x72\x45' \
+            b'\x85\x8a\x0f\x4c' b'\x96\x0c\x0c\x39' \
+            b'\xa5\x76\xc5\x60' b'\x0b\x59\x99\x04' \
+            b'\x2d\xc9\x0e\x19' b'\xcd\x4b\x1e\x2f' \
+            b'\xc7\x8d\xd3\x41' b'\x70\x55\x11\x62' \
+            b'\x17\x18\x6c\x34' b'\xb3\x4d\xd4\x14' \
+            b'\xc1\x35\x4f\x4e' b'\xa2\x1d\xe5\x15' \
+            b'\xde\xee\xfd\x47' b'\x1a\xee\xa4\x1e' \
+            b'\x99\xce\xbd\x2d' b'\x60\x22\x11\x08' \
+            b'\x67\x1d\x14\x2d' b'\x04\xae\x56\x1c' \
+            b'\xaf\xbe\xbe\x7b' b'\x8a\x4c\xae\x4a' \
+            b'\x41\x3e\x76\x39' b'\x31\x14\xa0\x77' \
+            b'\xb6\xbb\x86\x38' b'\x67\x61\xab\x72' \
+            b'\xfe\xa9\x3f\x3f' b'\x8a\x97\xa7\x4e' \
+            b'\xa1\x25\xb9\x46' b'\x85\xc1\x82\x69' \
+            b'\x04\x72\xa3\x2a' b'\x8f\xc4\xa5\x57' \
+            b'\x50\xb0\x08\x18' b'\x1c\x85\x05\x0f' \
+            b'\x0c\xcc\x7f\x0f' b'\x43\xb2\x96\x5c' \
+            b'\xeb\x99\x5a\x41' b'\x4d\x04\xdf\x78' \
+            b'\xb2\xe8\xc4\x76' b'\xc4\x39\xd1\x16'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangeKeyboardMapping._request.to_binary, (), self.req_args_0)
+        bin = request.ChangeKeyboardMapping._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4743,50 +4751,50 @@
             'first_keycode': 174,
             'count': 233,
             }
-        self.req_bin_0 = '\x65\x00\x02\x00' '\xae\xe9\x00\x00'
+        self.req_bin_0 = b'\x65\x00\x02\x00' b'\xae\xe9\x00\x00'
 
         self.reply_args_0 = {
             'keysyms': [[536700486, 90972970, 1834434734], [604690854, 1612992766, 1785113276], [1258017014, 814047417, 79874791], [1752913778, 2069894554, 1342993084], [691283205, 2002270597, 1552550365], [1427239047, 80222814, 380890249], [932130695, 1233544402, 1343201446], [850296480, 830996690, 1219102856], [1427529259, 1334110395, 1423305447], [925543758, 1154246092, 389857513], [782217983, 1673349321, 296773941], [904384636, 788791004, 1427343811], [578056967, 1628142600, 882651915], [1727003528, 1202959768, 59536638], [932784259, 453243643, 1846802632], [1527858524, 2055184942, 1534128611], [134086768, 909769847, 323736641], [2080620639, 1573387975, 566724688], [1393924270, 1408645244, 1610610798], [391612329, 341605408, 484634403]],
             'sequence_number': 27901,
             }
-        self.reply_bin_0 = '\x01\x03\xfd\x6c' '\x3c\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x46\x66\xfd\x1f' '\x2a\x23\x6c\x05' \
-            '\xae\x40\x57\x6d' '\xa6\xd9\x0a\x24' \
-            '\xfe\x50\x24\x60' '\xbc\xaa\x66\x6a' \
-            '\xf6\xd0\xfb\x4a' '\xb9\x60\x85\x30' \
-            '\xe7\xca\xc2\x04' '\x72\x57\x7b\x68' \
-            '\x9a\x15\x60\x7b' '\xbc\x72\x0c\x50' \
-            '\x05\x25\x34\x29' '\x85\x39\x58\x77' \
-            '\xdd\x09\x8a\x5c' '\x87\xf0\x11\x55' \
-            '\x5e\x1a\xc8\x04' '\x89\xec\xb3\x16' \
-            '\x87\x2f\x8f\x37' '\xd2\x64\x86\x49' \
-            '\xa6\xa0\x0f\x50' '\xa0\x7e\xae\x32' \
-            '\xd2\x00\x88\x31' '\x88\x08\xaa\x48' \
-            '\x2b\x5e\x16\x55' '\xbb\xe8\x84\x4f' \
-            '\xe7\xea\xd5\x54' '\x4e\xad\x2a\x37' \
-            '\xcc\x65\xcc\x44' '\xe9\xc0\x3c\x17' \
-            '\xff\xb2\x9f\x2e' '\xc9\x48\xbd\x63' \
-            '\x35\x69\xb0\x11' '\x7c\xd0\xe7\x35' \
-            '\xdc\xfe\x03\x2f' '\xc3\x89\x13\x55' \
-            '\x07\x73\x74\x22' '\x08\x7c\x0b\x61' \
-            '\x0b\x33\x9c\x34' '\x88\xfb\xef\x66' \
-            '\x98\xb5\xb3\x47' '\xfe\x74\x8c\x03' \
-            '\x83\x28\x99\x37' '\xfb\xf2\x03\x1b' \
-            '\xc8\xf8\x13\x6e' '\x5c\x45\x11\x5b' \
-            '\x2e\xa2\x7f\x7a' '\xe3\xf1\x70\x5b' \
-            '\x70\x00\xfe\x07' '\x77\xfc\x39\x36' \
-            '\x41\xd4\x4b\x13' '\x5f\xc0\x03\x7c' \
-            '\xc7\xfe\xc7\x5d' '\x50\x88\xc7\x21' \
-            '\xae\x98\x15\x53' '\x7c\x38\xf6\x53' \
-            '\x6e\xf8\xff\x5f' '\xa9\x87\x57\x17' \
-            '\x20\x7c\x5c\x14' '\x23\xef\xe2\x1c'
+        self.reply_bin_0 = b'\x01\x03\xfd\x6c' b'\x3c\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x46\x66\xfd\x1f' b'\x2a\x23\x6c\x05' \
+            b'\xae\x40\x57\x6d' b'\xa6\xd9\x0a\x24' \
+            b'\xfe\x50\x24\x60' b'\xbc\xaa\x66\x6a' \
+            b'\xf6\xd0\xfb\x4a' b'\xb9\x60\x85\x30' \
+            b'\xe7\xca\xc2\x04' b'\x72\x57\x7b\x68' \
+            b'\x9a\x15\x60\x7b' b'\xbc\x72\x0c\x50' \
+            b'\x05\x25\x34\x29' b'\x85\x39\x58\x77' \
+            b'\xdd\x09\x8a\x5c' b'\x87\xf0\x11\x55' \
+            b'\x5e\x1a\xc8\x04' b'\x89\xec\xb3\x16' \
+            b'\x87\x2f\x8f\x37' b'\xd2\x64\x86\x49' \
+            b'\xa6\xa0\x0f\x50' b'\xa0\x7e\xae\x32' \
+            b'\xd2\x00\x88\x31' b'\x88\x08\xaa\x48' \
+            b'\x2b\x5e\x16\x55' b'\xbb\xe8\x84\x4f' \
+            b'\xe7\xea\xd5\x54' b'\x4e\xad\x2a\x37' \
+            b'\xcc\x65\xcc\x44' b'\xe9\xc0\x3c\x17' \
+            b'\xff\xb2\x9f\x2e' b'\xc9\x48\xbd\x63' \
+            b'\x35\x69\xb0\x11' b'\x7c\xd0\xe7\x35' \
+            b'\xdc\xfe\x03\x2f' b'\xc3\x89\x13\x55' \
+            b'\x07\x73\x74\x22' b'\x08\x7c\x0b\x61' \
+            b'\x0b\x33\x9c\x34' b'\x88\xfb\xef\x66' \
+            b'\x98\xb5\xb3\x47' b'\xfe\x74\x8c\x03' \
+            b'\x83\x28\x99\x37' b'\xfb\xf2\x03\x1b' \
+            b'\xc8\xf8\x13\x6e' b'\x5c\x45\x11\x5b' \
+            b'\x2e\xa2\x7f\x7a' b'\xe3\xf1\x70\x5b' \
+            b'\x70\x00\xfe\x07' b'\x77\xfc\x39\x36' \
+            b'\x41\xd4\x4b\x13' b'\x5f\xc0\x03\x7c' \
+            b'\xc7\xfe\xc7\x5d' b'\x50\x88\xc7\x21' \
+            b'\xae\x98\x15\x53' b'\x7c\x38\xf6\x53' \
+            b'\x6e\xf8\xff\x5f' b'\xa9\x87\x57\x17' \
+            b'\x20\x7c\x5c\x14' b'\x23\xef\xe2\x1c'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetKeyboardMapping._request.to_binary, (), self.req_args_0)
+        bin = request.GetKeyboardMapping._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4804,7 +4812,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetKeyboardMapping._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetKeyboardMapping._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4827,15 +4835,15 @@
         self.req_args_0 = {
             'attrs': {'led': 241, 'key': 193, 'bell_duration': -19485, 'auto_repeat_mode': 0, 'bell_pitch': -13220, 'key_click_percent': -3, 'bell_percent': -74, 'led_mode': 1},
             }
-        self.req_bin_0 = '\x66\x00\x0a\x00' '\xff\x00\x00\x00' \
-            '\xfd\x00\x00\x00' '\xb6\x00\x00\x00' \
-            '\x5c\xcc\x00\x00' '\xe3\xb3\x00\x00' \
-            '\xf1\x00\x00\x00' '\x01\x00\x00\x00' \
-            '\xc1\x00\x00\x00' '\x00\x00\x00\x00'
+        self.req_bin_0 = b'\x66\x00\x0a\x00' b'\xff\x00\x00\x00' \
+            b'\xfd\x00\x00\x00' b'\xb6\x00\x00\x00' \
+            b'\x5c\xcc\x00\x00' b'\xe3\xb3\x00\x00' \
+            b'\xf1\x00\x00\x00' b'\x01\x00\x00\x00' \
+            b'\xc1\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangeKeyboardControl._request.to_binary, (), self.req_args_0)
+        bin = request.ChangeKeyboardControl._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4857,7 +4865,7 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x67\x00\x01\x00'
+        self.req_bin_0 = b'\x67\x00\x01\x00'
 
         self.reply_args_0 = {
             'led_mask': 1389423883,
@@ -4869,17 +4877,17 @@
             'sequence_number': 62321,
             'key_click_percent': 140,
             }
-        self.reply_bin_0 = '\x01\x01\x71\xf3' '\x05\x00\x00\x00' \
-            '\x0b\xed\xd0\x52' '\x8c\x82\xb8\x6b' \
-            '\xca\x66\x00\x00' '\x81\xd3\xb4\xca' \
-            '\xda\x91\x81\x88' '\x89\xa5\xd2\xa0' \
-            '\xe5\xdf\xe2\x82' '\xc5\xe9\xbb\xa6' \
-            '\xd3\xf1\xad\xb7' '\xb8\xd8\xd8\xda' \
-            '\xb6\xe0\xaf\xd2'
+        self.reply_bin_0 = b'\x01\x01\x71\xf3' b'\x05\x00\x00\x00' \
+            b'\x0b\xed\xd0\x52' b'\x8c\x82\xb8\x6b' \
+            b'\xca\x66\x00\x00' b'\x81\xd3\xb4\xca' \
+            b'\xda\x91\x81\x88' b'\x89\xa5\xd2\xa0' \
+            b'\xe5\xdf\xe2\x82' b'\xc5\xe9\xbb\xa6' \
+            b'\xd3\xf1\xad\xb7' b'\xb8\xd8\xd8\xda' \
+            b'\xb6\xe0\xaf\xd2'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetKeyboardControl._request.to_binary, (), self.req_args_0)
+        bin = request.GetKeyboardControl._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4897,7 +4905,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetKeyboardControl._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetKeyboardControl._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -4920,11 +4928,11 @@
         self.req_args_0 = {
             'percent': -14,
             }
-        self.req_bin_0 = '\x68\xf2\x01\x00'
+        self.req_bin_0 = b'\x68\xf2\x01\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.Bell._request.to_binary, (), self.req_args_0)
+        bin = request.Bell._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4951,12 +4959,12 @@
             'accel_denum': -24572,
             'do_thresh': 1,
             }
-        self.req_bin_0 = '\x69\x00\x03\x00' '\x4e\xea\x04\xa0' \
-            '\xba\xd6\x01\x01'
+        self.req_bin_0 = b'\x69\x00\x03\x00' b'\x4e\xea\x04\xa0' \
+            b'\xba\xd6\x01\x01'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangePointerControl._request.to_binary, (), self.req_args_0)
+        bin = request.ChangePointerControl._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -4978,7 +4986,7 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x6a\x00\x01\x00'
+        self.req_bin_0 = b'\x6a\x00\x01\x00'
 
         self.reply_args_0 = {
             'accel_num': 11888,
@@ -4986,14 +4994,14 @@
             'sequence_number': 62480,
             'accel_denom': 46073,
             }
-        self.reply_bin_0 = '\x01\x00\x10\xf4' '\x00\x00\x00\x00' \
-            '\x70\x2e\xf9\xb3' '\xd6\x8f\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\x10\xf4' b'\x00\x00\x00\x00' \
+            b'\x70\x2e\xf9\xb3' b'\xd6\x8f\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetPointerControl._request.to_binary, (), self.req_args_0)
+        bin = request.GetPointerControl._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5011,7 +5019,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetPointerControl._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetPointerControl._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -5037,12 +5045,12 @@
             'timeout': -2423,
             'allow_exposures': 2,
             }
-        self.req_bin_0 = '\x6b\x00\x03\x00' '\x89\xf6\xee\xb4' \
-            '\x01\x02\x00\x00'
+        self.req_bin_0 = b'\x6b\x00\x03\x00' b'\x89\xf6\xee\xb4' \
+            b'\x01\x02\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetScreenSaver._request.to_binary, (), self.req_args_0)
+        bin = request.SetScreenSaver._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5064,7 +5072,7 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x6c\x00\x01\x00'
+        self.req_bin_0 = b'\x6c\x00\x01\x00'
 
         self.reply_args_0 = {
             'interval': 51464,
@@ -5073,14 +5081,14 @@
             'sequence_number': 45153,
             'allow_exposures': 1,
             }
-        self.reply_bin_0 = '\x01\x00\x61\xb0' '\x00\x00\x00\x00' \
-            '\x57\x14\x08\xc9' '\x01\x01\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x00\x61\xb0' b'\x00\x00\x00\x00' \
+            b'\x57\x14\x08\xc9' b'\x01\x01\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetScreenSaver._request.to_binary, (), self.req_args_0)
+        bin = request.GetScreenSaver._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5098,7 +5106,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetScreenSaver._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetScreenSaver._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -5123,12 +5131,12 @@
             'mode': 0,
             'host_family': 0,
             }
-        self.req_bin_0 = '\x6d\x00\x03\x00' '\x00\x00\x04\x00' \
-            '\x96\xc8\xcd\xb6'
+        self.req_bin_0 = b'\x6d\x00\x03\x00' b'\x00\x00\x04\x00' \
+            b'\x96\xc8\xcd\xb6'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ChangeHosts._request.to_binary, (), self.req_args_0)
+        bin = request.ChangeHosts._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5150,23 +5158,23 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x6e\x00\x01\x00'
+        self.req_bin_0 = b'\x6e\x00\x01\x00'
 
         self.reply_args_0 = {
             'hosts': [{'name': [34, 23, 178, 12], 'family': 0}, {'name': [130, 236, 254, 15], 'family': 0}],
             'mode': 1,
             'sequence_number': 33455,
             }
-        self.reply_bin_0 = '\x01\x01\xaf\x82' '\x04\x00\x00\x00' \
-            '\x02\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x04\x00' '\x22\x17\xb2\x0c' \
-            '\x00\x00\x04\x00' '\x82\xec\xfe\x0f'
+        self.reply_bin_0 = b'\x01\x01\xaf\x82' b'\x04\x00\x00\x00' \
+            b'\x02\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x04\x00' b'\x22\x17\xb2\x0c' \
+            b'\x00\x00\x04\x00' b'\x82\xec\xfe\x0f'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ListHosts._request.to_binary, (), self.req_args_0)
+        bin = request.ListHosts._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5184,7 +5192,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.ListHosts._reply.to_binary, (), self.reply_args_0)
+        bin = request.ListHosts._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -5207,11 +5215,11 @@
         self.req_args_0 = {
             'mode': 1,
             }
-        self.req_bin_0 = '\x6f\x01\x01\x00'
+        self.req_bin_0 = b'\x6f\x01\x01\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetAccessControl._request.to_binary, (), self.req_args_0)
+        bin = request.SetAccessControl._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5234,11 +5242,11 @@
         self.req_args_0 = {
             'mode': 1,
             }
-        self.req_bin_0 = '\x70\x01\x01\x00'
+        self.req_bin_0 = b'\x70\x01\x01\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetCloseDownMode._request.to_binary, (), self.req_args_0)
+        bin = request.SetCloseDownMode._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5261,11 +5269,11 @@
         self.req_args_0 = {
             'resource': 1900634441,
             }
-        self.req_bin_0 = '\x71\x00\x02\x00' '\x49\x61\x49\x71'
+        self.req_bin_0 = b'\x71\x00\x02\x00' b'\x49\x61\x49\x71'
 
 
     def testPackRequest0(self):
-        bin = apply(request.KillClient._request.to_binary, (), self.req_args_0)
+        bin = request.KillClient._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5290,18 +5298,18 @@
             'properties': [194806244, 1444715269, 486779871, 1850032482, 1083061497, 786546027, 807635511, 1716883082, 80335197, 1654299, 1459844212, 850673646],
             'delta': -27029,
             }
-        self.req_bin_0 = '\x72\x00\x0f\x00' '\xfd\x1b\x7e\x44' \
-            '\x0c\x00\x6b\x96' '\xe4\x81\x9c\x0b' \
-            '\x05\x9b\x1c\x56' '\xdf\xab\x03\x1d' \
-            '\x62\x41\x45\x6e' '\xf9\x34\x8e\x40' \
-            '\x6b\xbd\xe1\x2e' '\x37\x8a\x23\x30' \
-            '\x8a\x8e\x55\x66' '\x5d\xd1\xc9\x04' \
-            '\x1b\x3e\x19\x00' '\x74\x74\x03\x57' \
-            '\xee\x3f\xb4\x32'
+        self.req_bin_0 = b'\x72\x00\x0f\x00' b'\xfd\x1b\x7e\x44' \
+            b'\x0c\x00\x6b\x96' b'\xe4\x81\x9c\x0b' \
+            b'\x05\x9b\x1c\x56' b'\xdf\xab\x03\x1d' \
+            b'\x62\x41\x45\x6e' b'\xf9\x34\x8e\x40' \
+            b'\x6b\xbd\xe1\x2e' b'\x37\x8a\x23\x30' \
+            b'\x8a\x8e\x55\x66' b'\x5d\xd1\xc9\x04' \
+            b'\x1b\x3e\x19\x00' b'\x74\x74\x03\x57' \
+            b'\xee\x3f\xb4\x32'
 
 
     def testPackRequest0(self):
-        bin = apply(request.RotateProperties._request.to_binary, (), self.req_args_0)
+        bin = request.RotateProperties._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5324,11 +5332,11 @@
         self.req_args_0 = {
             'mode': 1,
             }
-        self.req_bin_0 = '\x73\x01\x01\x00'
+        self.req_bin_0 = b'\x73\x01\x01\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.ForceScreenSaver._request.to_binary, (), self.req_args_0)
+        bin = request.ForceScreenSaver._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5351,21 +5359,21 @@
         self.req_args_0 = {
             'map': [130, 178, 229, 218, 178],
             }
-        self.req_bin_0 = '\x74\x05\x03\x00' '\x82\xb2\xe5\xda' \
-            '\xb2\x00\x00\x00'
+        self.req_bin_0 = b'\x74\x05\x03\x00' b'\x82\xb2\xe5\xda' \
+            b'\xb2\x00\x00\x00'
 
         self.reply_args_0 = {
             'status': 145,
             'sequence_number': 57045,
             }
-        self.reply_bin_0 = '\x01\x91\xd5\xde' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x91\xd5\xde' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetPointerMapping._request.to_binary, (), self.req_args_0)
+        bin = request.SetPointerMapping._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5383,7 +5391,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.SetPointerMapping._reply.to_binary, (), self.reply_args_0)
+        bin = request.SetPointerMapping._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -5405,21 +5413,21 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x75\x00\x01\x00'
+        self.req_bin_0 = b'\x75\x00\x01\x00'
 
         self.reply_args_0 = {
             'map': [248, 185, 227, 157, 133],
             'sequence_number': 20072,
             }
-        self.reply_bin_0 = '\x01\x05\x68\x4e' '\x02\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\xf8\xb9\xe3\x9d' '\x85\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x05\x68\x4e' b'\x02\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\xf8\xb9\xe3\x9d' b'\x85\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetPointerMapping._request.to_binary, (), self.req_args_0)
+        bin = request.GetPointerMapping._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5437,7 +5445,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetPointerMapping._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetPointerMapping._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -5460,22 +5468,22 @@
         self.req_args_0 = {
             'keycodes': [[6, 191], [94, 123], [46, 94], [104, 116], [132, 158], [35, 75], [128, 63], [135, 221]],
             }
-        self.req_bin_0 = '\x76\x02\x05\x00' '\x06\xbf\x5e\x7b' \
-            '\x2e\x5e\x68\x74' '\x84\x9e\x23\x4b' \
-            '\x80\x3f\x87\xdd'
+        self.req_bin_0 = b'\x76\x02\x05\x00' b'\x06\xbf\x5e\x7b' \
+            b'\x2e\x5e\x68\x74' b'\x84\x9e\x23\x4b' \
+            b'\x80\x3f\x87\xdd'
 
         self.reply_args_0 = {
             'status': 149,
             'sequence_number': 26757,
             }
-        self.reply_bin_0 = '\x01\x95\x85\x68' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00'
+        self.reply_bin_0 = b'\x01\x95\x85\x68' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.SetModifierMapping._request.to_binary, (), self.req_args_0)
+        bin = request.SetModifierMapping._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5493,7 +5501,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.SetModifierMapping._reply.to_binary, (), self.reply_args_0)
+        bin = request.SetModifierMapping._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -5515,22 +5523,22 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x77\x00\x01\x00'
+        self.req_bin_0 = b'\x77\x00\x01\x00'
 
         self.reply_args_0 = {
             'keycodes': [[85, 162], [139, 194], [12, 107], [120, 193], [26, 40], [125, 221], [27, 0], [220, 78]],
             'sequence_number': 17677,
             }
-        self.reply_bin_0 = '\x01\x02\x0d\x45' '\x04\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x00\x00\x00\x00' '\x00\x00\x00\x00' \
-            '\x55\xa2\x8b\xc2' '\x0c\x6b\x78\xc1' \
-            '\x1a\x28\x7d\xdd' '\x1b\x00\xdc\x4e'
+        self.reply_bin_0 = b'\x01\x02\x0d\x45' b'\x04\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x00\x00\x00\x00' b'\x00\x00\x00\x00' \
+            b'\x55\xa2\x8b\xc2' b'\x0c\x6b\x78\xc1' \
+            b'\x1a\x28\x7d\xdd' b'\x1b\x00\xdc\x4e'
 
 
     def testPackRequest0(self):
-        bin = apply(request.GetModifierMapping._request.to_binary, (), self.req_args_0)
+        bin = request.GetModifierMapping._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
@@ -5548,7 +5556,7 @@
             raise AssertionError(args)
 
     def testPackReply0(self):
-        bin = apply(request.GetModifierMapping._reply.to_binary, (), self.reply_args_0)
+        bin = request.GetModifierMapping._reply.to_binary(*(), **self.reply_args_0)
         try:
             assert bin == self.reply_bin_0
         except AssertionError:
@@ -5570,11 +5578,11 @@
     def setUp(self):
         self.req_args_0 = {
             }
-        self.req_bin_0 = '\x7f\x00\x01\x00'
+        self.req_bin_0 = b'\x7f\x00\x01\x00'
 
 
     def testPackRequest0(self):
-        bin = apply(request.NoOperation._request.to_binary, (), self.req_args_0)
+        bin = request.NoOperation._request.to_binary(*(), **self.req_args_0)
         try:
             assert bin == self.req_bin_0
         except AssertionError:
Index: python-xlib-0.14+20091101/Xlib/error.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/error.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/error.py	2013-10-11 14:19:21.113971349 -0400
@@ -16,11 +16,8 @@
 #    along with this program; if not, write to the Free Software
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-# Standard modules
-import string
-
 # Xlib modules
-import X
+from Xlib import X
 
 # Xlib.protocol modules
 from Xlib.protocol import rq
@@ -78,7 +75,7 @@
                   'major_opcode', 'minor_opcode'):
             s.append('%s = %s' % (f, self._data[f]))
 
-        return '%s: %s' % (self.__class__, string.join(s, ', '))
+        return '%s: %s' % (self.__class__, ', '.join(s))
 
 class XResourceError(XError):
     _fields = rq.Struct( rq.Card8('type'),  # Always 0
Index: python-xlib-0.14+20091101/Xlib/protocol/event.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/protocol/event.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/protocol/event.py	2013-10-11 14:19:21.113971349 -0400
@@ -21,7 +21,7 @@
 from Xlib import X
 
 # Xlib.protocol modules
-import rq
+from Xlib.protocol import rq
 
 
 class AnyEvent(rq.Event):
Index: python-xlib-0.14+20091101/Xlib/XK.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/XK.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/XK.py	2013-10-11 14:19:21.113971349 -0400
@@ -20,7 +20,7 @@
 # as a modular keysym definition and loading mechanism. See the keysym
 # definition modules in the Xlib/keysymdef directory.
 
-from X import NoSymbol
+from Xlib.X import NoSymbol
 
 def string_to_keysym(keysym):
     '''Return the (16 bit) numeric code of keysym.
Index: python-xlib-0.14+20091101/Xlib/ext/randr.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/ext/randr.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/ext/randr.py	2013-10-11 14:19:21.113971349 -0400
@@ -1139,7 +1139,7 @@
 # Initialization #
 
 def init(disp, info):
-    print info.__class__
+    print(info.__class__)
 
     disp.extension_add_method('display', 'xrandr_query_version', query_version)
     disp.extension_add_method('window', 'xrandr_select_input', select_input)
Index: python-xlib-0.14+20091101/Xlib/ext/record.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/ext/record.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/ext/record.py	2013-10-11 14:19:21.113971349 -0400
@@ -71,7 +71,7 @@
         return val, len(val), None
 
     def parse_binary_value(self, data, display, length, format):
-        return str(data), ''
+        return data, ''
 
 
 class GetVersion(rq.ReplyRequest):
@@ -212,7 +212,7 @@
 
     def __init__(self, callback, *args, **keys):
         self._callback = callback
-        apply(rq.ReplyRequest.__init__, (self, ) + args, keys)
+        rq.ReplyRequest.__init__(self, *args, **keys)
 
     def _parse_response(self, data):
         r, d = self._reply.parse_binary(data, self._display)
Index: python-xlib-0.14+20091101/Xlib/xobject/colormap.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/xobject/colormap.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/xobject/colormap.py	2013-10-11 14:19:21.113971349 -0400
@@ -18,8 +18,7 @@
 
 from Xlib import error
 from Xlib.protocol import request
-
-import resource
+from Xlib.xobject import resource
 
 import re
 import string
Index: python-xlib-0.14+20091101/Xlib/threaded.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/threaded.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/threaded.py	2013-10-11 14:19:21.113971349 -0400
@@ -16,7 +16,12 @@
 #    along with this program; if not, write to the Free Software
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-import thread
+try:
+    # Python 3
+    import _thread as thread
+except ImportError:
+    # Python 2
+    import thread
 
 # We change the allocate_lock function in Xlib.support.lock to
 # return a basic Python lock, instead of the default dummy lock
Index: python-xlib-0.14+20091101/Xlib/xobject/resource.py
===================================================================
--- python-xlib-0.14+20091101.orig/Xlib/xobject/resource.py	2013-10-11 14:19:21.117971349 -0400
+++ python-xlib-0.14+20091101/Xlib/xobject/resource.py	2013-10-11 14:19:21.113971349 -0400
@@ -27,14 +27,14 @@
     def __resource__(self):
         return self.id
 
-    def __cmp__(self, obj):
+    def __eq__(self, obj):
         if isinstance(obj, Resource):
             if self.display == obj.display:
-                return cmp(self.id, obj.id)
+                return self.id == obj.id
             else:
-                return cmp(self.display, obj.display)
+                return self.display == obj.display
         else:
-            return cmp(id(self), id(obj))
+            return id(self) == id(obj)
 
     def __hash__(self):
         return int(self.id)
