def ext_hook(self, code, data):
    if (code == 48):
        (real, imag) = struct.unpack('dd', data)
        return complex(real, imag)
    if (code == 49):
        return int(data)
    if (code == 50):
        return datetime.datetime.fromtimestamp(struct.unpack('d', data)[0])
    if (code == 51):
        return datetime.date.fromordinal(struct.unpack('l', data)[0])
    raise errors.SerializeError(('invalid ext code for msgpack: ' + str(code)))
def ext_hook(self, code, data):
    if (code == 48):
        (real, imag) = struct.unpack('dd', data)
        return complex(real, imag)
    if (code == 49):
        return int(data)
    if (code == 50):
        return datetime.datetime.fromtimestamp(struct.unpack('d', data)[0])
    if (code == 51):
        return datetime.date.fromordinal(struct.unpack('l', data)[0])
    raise errors.SerializeError(('invalid ext code for msgpack: ' + str(code)))