From fd1221d5a03148e7a7455d0ff5f198e8e5fe5723 Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Fri, 2 Feb 2018 13:44:23 -0800 Subject: [PATCH] handle node names which are null --- rclpy/src/rclpy/_rclpy.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rclpy/src/rclpy/_rclpy.c b/rclpy/src/rclpy/_rclpy.c index 0a0bb377f..d2aac3e06 100644 --- a/rclpy/src/rclpy/_rclpy.c +++ b/rclpy/src/rclpy/_rclpy.c @@ -2525,8 +2525,13 @@ rclpy_get_node_names(PyObject * Py_UNUSED(self), PyObject * args) PyObject * pynode_names = PyList_New(node_names.size); size_t idx; for (idx = 0; idx < node_names.size; ++idx) { - PyList_SetItem( - pynode_names, idx, PyUnicode_FromString(node_names.data[idx])); + if (node_names.data[idx]) { + PyList_SetItem( + pynode_names, idx, PyUnicode_FromString(node_names.data[idx])); + } else { + Py_INCREF(Py_None); + PyList_SetItem(pynode_names, idx, Py_None); + } } ret = rcutils_string_array_fini(&node_names);