Cleanup: use PyErr_SetString when formatting isn't needed
This commit is contained in:
@@ -581,7 +581,7 @@ static PyObject *imbuf_load_from_memory_impl(const char *buffer,
|
||||
reinterpret_cast<const uchar *>(buffer), buffer_size, flags, "<imbuf.load_from_buffer>");
|
||||
|
||||
if (ibuf == nullptr) {
|
||||
PyErr_Format(PyExc_ValueError, "load_from_buffer: Unable to load image from memory");
|
||||
PyErr_SetString(PyExc_ValueError, "load_from_buffer: Unable to load image from memory");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ static bool pygpu_buffer_dimensions_tot_len_compare(const Py_ssize_t *shape_a,
|
||||
if (pygpu_buffer_dimensions_tot_elem(shape_a, shape_a_len) !=
|
||||
pygpu_buffer_dimensions_tot_elem(shape_b, shape_b_len))
|
||||
{
|
||||
PyErr_Format(PyExc_BufferError, "array size does not match");
|
||||
PyErr_SetString(PyExc_BufferError, "array size does not match");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,9 +56,9 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject * /*type*/, PyObject *args,
|
||||
|
||||
verts_per_prim = GPU_indexbuf_primitive_len(GPUPrimType(prim_type.value_found));
|
||||
if (verts_per_prim == -1) {
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
"The argument 'type' must be "
|
||||
"'POINTS', 'LINES', 'TRIS', 'LINES_ADJ' or 'TRIS_ADJ'");
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"The argument 'type' must be "
|
||||
"'POINTS', 'LINES', 'TRIS', 'LINES_ADJ' or 'TRIS_ADJ'");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject * /*type*/, PyObject *args,
|
||||
if (pybuffer.itemsize != 4 ||
|
||||
PyC_StructFmt_type_is_float_any(PyC_StructFmt_type_from_str(pybuffer.format)))
|
||||
{
|
||||
PyErr_Format(PyExc_ValueError, "Each index must be an 4-bytes integer value");
|
||||
PyErr_SetString(PyExc_ValueError, "Each index must be an 4-bytes integer value");
|
||||
PyBuffer_Release(&pybuffer);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -965,7 +965,7 @@ static PyObject *pygpu_shader_from_builtin(PyObject * /*self*/, PyObject *args,
|
||||
eGPUShaderConfig(pygpu_config.value_found));
|
||||
|
||||
if (shader == nullptr) {
|
||||
PyErr_Format(PyExc_ValueError, "Builtin shader doesn't exist in the requested config");
|
||||
PyErr_SetString(PyExc_ValueError, "Builtin shader doesn't exist in the requested config");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -2885,9 +2885,9 @@ static int pyrna_prop_collection_type_check(BPy_PropertyRNA *self, PyObject *val
|
||||
|
||||
if (value == Py_None) {
|
||||
if (RNA_property_flag(self->prop) & PROP_NEVER_NULL) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"bpy_prop_collection[key] = value: invalid, "
|
||||
"this collection doesn't support None assignment");
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"bpy_prop_collection[key] = value: invalid, "
|
||||
"this collection doesn't support None assignment");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2914,9 +2914,9 @@ static int pyrna_prop_collection_type_check(BPy_PropertyRNA *self, PyObject *val
|
||||
return 0; /* OK, this is the correct type! */
|
||||
}
|
||||
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"bpy_prop_collection[key] = value: internal error, "
|
||||
"failed to get the collection type");
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"bpy_prop_collection[key] = value: internal error, "
|
||||
"failed to get the collection type");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -5974,7 +5974,7 @@ static PyObject *pyprop_array_foreach_getset(BPy_PropertyArrayRNA *self,
|
||||
PyObject *seq;
|
||||
|
||||
if (!ELEM(prop_type, PROP_INT, PROP_FLOAT)) {
|
||||
PyErr_Format(PyExc_TypeError, "foreach_get/set available only for int and float");
|
||||
PyErr_SetString(PyExc_TypeError, "foreach_get/set available only for int and float");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -652,7 +652,7 @@ int _BaseMathObject_RaiseBufferViewExc(BaseMathObject *self, Py_buffer *view, in
|
||||
return -1;
|
||||
}
|
||||
if (UNLIKELY(self->flag & BASE_MATH_FLAG_IS_FROZEN)) {
|
||||
PyErr_Format(PyExc_BufferError, "Data is frozen, cannot get a writable buffer");
|
||||
PyErr_SetString(PyExc_BufferError, "Data is frozen, cannot get a writable buffer");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user