def convert_value_to_type(str_value, python_type_name):
    """
    Converts a value to a specific Python primitive type.

    :param python_type_name: Python primitive type name (case insensitive)
    :raises ~exceptions.ValueError: for unsupported types or conversion failure
    """

    python_type_name = python_type_name.lower()
    try:
        if python_type_name in ('str', 'unicode'):
            return str_value.decode('utf-8')
        elif python_type_name == 'int':
            return int(str_value)
        elif python_type_name == 'bool':
            return bool(str_value)
        elif python_type_name == 'float':
            return float(str_value)
        else:
            raise ValueError('Unsupported Python type name: {0}'.format(python_type_name))
    except ValueError:
        raise ValueError('Failed to to convert {0} to {1}'.format(str_value,
                                                                  python_type_name))