def __deserialize_primitive(data, klass):
    """
    Deserializes string to primitive type.
    """
    try:
        return klass(data)
    except UnicodeEncodeError:
        return data
    except TypeError:
        return data
