Cleanup: avoid "nullptr" in Python strings & error messages

This is a C++ term not expected in exceptions and messages.
This commit is contained in:
Campbell Barton
2025-08-12 13:32:41 +10:00
parent 570eb9c60a
commit f96a73961a
3 changed files with 9 additions and 8 deletions

View File

@@ -4576,7 +4576,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
bContext *C = static_cast<bContext *>(self->ptr->data);
if (C == nullptr) {
PyErr_Format(PyExc_AttributeError,
"bpy_struct: Context is 'nullptr', cannot get \"%.200s\" from context",
"bpy_struct: Context is 'null', cannot get \"%.200s\" from context",
name);
ret = nullptr;
}
@@ -4862,7 +4862,7 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
bContext *C = static_cast<bContext *>(self->ptr->data);
if (C == nullptr) {
PyErr_Format(PyExc_AttributeError,
"bpy_struct: Context is 'nullptr', cannot set \"%.200s\" from context",
"bpy_struct: Context is 'null', cannot set \"%.200s\" from context",
name);
return -1;
}
@@ -6653,14 +6653,14 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
if (self_ptr == nullptr) {
PyErr_SetString(PyExc_RuntimeError,
"RNA functions internal RNA pointer is nullptr, this is a bug. aborting");
"RNA functions internal RNA pointer is null, this is a bug. aborting");
return nullptr;
}
if (self_func == nullptr) {
PyErr_Format(
PyExc_RuntimeError,
"%.200s.<unknown>(): RNA function internal function is nullptr, this is a bug. aborting",
"%.200s.<unknown>(): RNA function internal function is null, this is a bug. aborting",
RNA_struct_identifier(self_ptr->type));
return nullptr;
}

View File

@@ -433,6 +433,9 @@ static char *copy_value_single(PyObject *item,
return data;
}
/**
* \param data: Data array, may be null.
*/
static char *copy_values(PyObject *seq,
PointerRNA *ptr,
PropertyRNA *prop,
@@ -454,8 +457,6 @@ static char *copy_values(PyObject *seq,
* validating but fails later somehow, so include checks for safety.
*/
/* Note that 'data can be nullptr' */
if (seq_size == -1) {
return nullptr;
}

View File

@@ -171,7 +171,7 @@ PyObject *pyrna_callback_remove(BPy_StructRNA *self, PyObject *args)
if (handle == nullptr) {
PyErr_SetString(PyExc_ValueError,
"callback_remove(handle): nullptr handle given, invalid or already removed");
"callback_remove(handle): null handle given, invalid or already removed");
return nullptr;
}
@@ -386,7 +386,7 @@ PyObject *pyrna_callback_classmethod_remove(PyObject * /*self*/, PyObject *args)
handle = PyCapsule_GetPointer(py_handle, rna_capsual_id);
if (handle == nullptr) {
PyErr_SetString(PyExc_ValueError,
"callback_remove(handler): nullptr handler given, invalid or already removed");
"callback_remove(handler): null handler given, invalid or already removed");
return nullptr;
}