Skip to content

Commit 2230fd1

Browse files
committed
Used constexpr value for base object type name
1 parent b0d4e90 commit 2230fd1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

include/pybind11/class_support.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ extern "C" inline void pybind11_object_dealloc(PyObject *self) {
301301
needed in order to satisfy Python's requirements for multiple inheritance.
302302
Return value: New reference. */
303303
inline PyObject *make_object_base_type(PyTypeObject *metaclass) {
304-
auto name_obj = reinterpret_steal<object>(PYBIND11_FROM_STRING("pybind11_object"));
304+
constexpr auto *name = "pybind11_object";
305+
auto name_obj = reinterpret_steal<object>(PYBIND11_FROM_STRING(name));
305306

306307
/* Danger zone: from now (and until PyType_Ready), make sure to
307308
issue no Python C API calls which could potentially invoke the
@@ -317,7 +318,7 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass) {
317318
#endif
318319

319320
auto type = &heap_type->ht_type;
320-
type->tp_name = "pybind11_object";
321+
type->tp_name = name;
321322
type->tp_base = &PyBaseObject_Type;
322323
type->tp_basicsize = static_cast<ssize_t>(sizeof(instance));
323324
type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE;

0 commit comments

Comments
 (0)