From f96a73961aa7a970c66430bddb844bf01db25e6a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Aug 2025 13:32:41 +1000 Subject: [PATCH] Cleanup: avoid "nullptr" in Python strings & error messages This is a C++ term not expected in exceptions and messages. --- source/blender/python/intern/bpy_rna.cc | 8 ++++---- source/blender/python/intern/bpy_rna_array.cc | 5 +++-- source/blender/python/intern/bpy_rna_callback.cc | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/source/blender/python/intern/bpy_rna.cc b/source/blender/python/intern/bpy_rna.cc index 569c031c2cb..eee4a1682a1 100644 --- a/source/blender/python/intern/bpy_rna.cc +++ b/source/blender/python/intern/bpy_rna.cc @@ -4576,7 +4576,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) bContext *C = static_cast(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(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.(): RNA function internal function is nullptr, this is a bug. aborting", + "%.200s.(): RNA function internal function is null, this is a bug. aborting", RNA_struct_identifier(self_ptr->type)); return nullptr; } diff --git a/source/blender/python/intern/bpy_rna_array.cc b/source/blender/python/intern/bpy_rna_array.cc index 0a4d8eef778..e9f1ab1afd0 100644 --- a/source/blender/python/intern/bpy_rna_array.cc +++ b/source/blender/python/intern/bpy_rna_array.cc @@ -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; } diff --git a/source/blender/python/intern/bpy_rna_callback.cc b/source/blender/python/intern/bpy_rna_callback.cc index 95ca0965f4a..ae4e53f1079 100644 --- a/source/blender/python/intern/bpy_rna_callback.cc +++ b/source/blender/python/intern/bpy_rna_callback.cc @@ -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; }