def METHOD_NAME(data, klass):
    """Deserializes to primitive type.
    :param data: data to deserialize.
    :param klass: class literal.
    :return: int, long, float, str, bool.
    :rtype: int | long | float | str | bool
    """
    try:
        value = klass(data)
    except UnicodeEncodeError:
        value = six.u(data)
    except TypeError:
        value = data
    return value