PyAPI: throw exception when cycles is given an invalid device name

This commit is contained in:
Campbell Barton 2020-10-15 16:35:41 +11:00
parent c0dde8be84
commit 4bea4702d5
Notes: blender-bot 2023-02-14 09:03:55 +01:00
Referenced by commit 4d9f357bf6, Fix T81806: Cycles error when GPU device_type is NONE
1 changed files with 5 additions and 0 deletions

View File

@ -410,6 +410,11 @@ static PyObject *available_devices_func(PyObject * /*self*/, PyObject *args)
}
DeviceType type = Device::type_from_string(type_name);
if ((type == DEVICE_NONE) && (type_name[0] != '\0')) {
PyErr_Format(PyExc_ValueError, "Device \"%s\" not known.", type_name);
return NULL;
}
uint mask = (type == DEVICE_NONE) ? DEVICE_MASK_ALL : DEVICE_MASK(type);
mask |= DEVICE_MASK_CPU;