Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle node names which are null #177

Merged
merged 1 commit into from
Mar 30, 2018
Merged

Conversation

dirk-thomas
Copy link
Member

Necessary since each item can potentially contain a nullptr.

Connect to ros2/ros2#438.

@dirk-thomas dirk-thomas added the in review Waiting for review (Kanban column) label Feb 2, 2018
@dirk-thomas dirk-thomas self-assigned this Feb 2, 2018
@@ -2320,7 +2320,8 @@ rclpy_get_node_names(PyObject * Py_UNUSED(self), PyObject * args)
size_t idx;
for (idx = 0; idx < node_names.size; ++idx) {
PyList_SetItem(
pynode_names, idx, PyUnicode_FromString(node_names.data[idx]));
pynode_names, idx, PyUnicode_FromString(
node_names.data[idx] ? node_names.data[idx] : ""));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a difference between a null pointer and an empty string coming from rcl_get_node_names()? If so, maybe this should return Py_None instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely. Updated the patch to use Py_None.

@dirk-thomas dirk-thomas force-pushed the node_name_in_user_data branch from 6028605 to f2d08db Compare February 2, 2018 22:04
PyList_SetItem(
pynode_names, idx, PyUnicode_FromString(node_names.data[idx]));
pynode_names, idx, name ? PyUnicode_FromString(name) : Py_None);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Py_INCREF(Py_None) is needed here since PyList_SetItem steals a reference.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for catching this (again). Fixed in 9135c1c. Please feel free to point out the third flaw 😉

@dirk-thomas dirk-thomas force-pushed the node_name_in_user_data branch from f2d08db to 9135c1c Compare February 2, 2018 22:22
@dirk-thomas dirk-thomas force-pushed the node_name_in_user_data branch from 9135c1c to 9b60f4e Compare March 1, 2018 17:09
@mikaelarguedas mikaelarguedas added this to the bouncy milestone Mar 1, 2018
@dirk-thomas dirk-thomas force-pushed the node_name_in_user_data branch from 9b60f4e to e3eace5 Compare March 23, 2018 20:53
@dirk-thomas dirk-thomas force-pushed the node_name_in_user_data branch from e3eace5 to fd1221d Compare March 29, 2018 19:51
@dirk-thomas dirk-thomas merged commit 776f597 into master Mar 30, 2018
@dirk-thomas dirk-thomas deleted the node_name_in_user_data branch March 30, 2018 17:56
@dirk-thomas dirk-thomas removed the in review Waiting for review (Kanban column) label Mar 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants