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

Enforce UTF8 argv on rclpy.init() #273

Merged
merged 2 commits into from
Feb 12, 2019
Merged

Conversation

hidmic
Copy link
Contributor

@hidmic hidmic commented Feb 11, 2019

Connected to ros2/rcl#374. An additional check to provide better exception messages.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic hidmic added the in review Waiting for review (Kanban column) label Feb 11, 2019
@@ -501,6 +501,12 @@ rclpy_init(PyObject * Py_UNUSED(self), PyObject * args)
}
// Borrows a pointer, do not free arg_values[i]
arg_values[i] = PyUnicode_AsUTF8(pyarg);
if (NULL == arg_values[i]) {
PyErr_Format(
Copy link
Member

Choose a reason for hiding this comment

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

PyUnicode_AsUTF8 already sets an exception on error. I think you can omit this statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True that. Fixed!

- Remove redundant CPython error setting.
- Add a test case for non decodable UTF-8 in cmd args.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Copy link
Member

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

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

LGTM with green CI

@hidmic
Copy link
Contributor Author

hidmic commented Feb 12, 2019

@jacobperron copied from ros2/rcl#388 (comment):

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

@hidmic hidmic merged commit 1f09d33 into master Feb 12, 2019
@tfoote tfoote removed the in review Waiting for review (Kanban column) label Feb 12, 2019
@hidmic hidmic deleted the hidmic/check-for-non-utf8-argv branch February 12, 2019 18:08
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