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

rclpy_init() passes command line arguments to rcl_init() #179

Merged
merged 4 commits into from
Mar 6, 2018

Conversation

sloretz
Copy link
Contributor

@sloretz sloretz commented Mar 5, 2018

This passes command line arguments through to rcl. Previously there was only a TODO message. This PR allows python nodes to be remapped using ros2/rcl#217.

CI

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

connects to ros2/ros2#450

@sloretz sloretz added the in review Waiting for review (Kanban column) label Mar 5, 2018
@sloretz sloretz self-assigned this Mar 5, 2018
wjwwood
wjwwood previously approved these changes Mar 6, 2018
Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

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

Other than some questions (mostly just curious), this lgtm.

// Expect one argument which is a list of strings
PyObject * pyargs;
if (!PyArg_ParseTuple(args, "O", &pyargs)) {
return NULL;
Copy link
Member

Choose a reason for hiding this comment

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

Just to check, these functions setup the exceptions right? That's why only returning null here is fine?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, PyArg_ParseTuple returns false and sets an exception on failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comments about exceptions already being set in 023ccaf

if (NULL == pyargs) {
return NULL;
}
Py_ssize_t num_args = PyList_Size(pyargs);
Copy link
Member

Choose a reason for hiding this comment

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

I guess this cannot fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can raise SystemError and return -1 https://github.com/python/cpython/blob/745dc65b17b3936e3f9f4099f735f174d30c4e0c/Objects/listobject.c#L188 if PyList_Check returns false, but I don't think that's possible if PySequence_List above succeeds.

@sloretz
Copy link
Contributor Author

sloretz commented Mar 6, 2018

New CI after fixing a windows warning

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@sloretz sloretz dismissed wjwwood’s stale review March 6, 2018 16:43

New commits since review

}
// Borrows a pointer, do not free arg_values[i]
arg_values[i] = PyUnicode_AsUTF8(pyarg);
}
Copy link
Member

Choose a reason for hiding this comment

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

can we just skip this entire block (L180 to 197) when num_args is 0 and pass a NULL pointer to rcl_init instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Block skipped when no args in 93c634b

@sloretz
Copy link
Contributor Author

sloretz commented Mar 6, 2018

CI with 93c634b

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@sloretz sloretz merged commit 50ccfd8 into master Mar 6, 2018
@sloretz sloretz deleted the pass_args_to_rcl branch March 6, 2018 19:38
@sloretz sloretz removed the in review Waiting for review (Kanban column) label Mar 6, 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