-
Notifications
You must be signed in to change notification settings - Fork 126
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
return NULL when conversion fails for any reason #226
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
would it make sense to do the same (returning a NULL pointig PyObject) when the conversion fails the other way around? this is just a question, the patch looks good to me as is |
I don't understand what you mean with "the other way around" and why "return a NULL pointing PyObject". Can you please clarify.
I found this while debugging the case in ros2/rclpy#95 and tried to fix the error handling. |
Oh I miss that related PR.
By "the other way around" I meant when we fail to convert from C to Python. In several places we assert that the result is valid (including in this function for the other types without error checking, e.g. PyFloat_AS_DOUBLE). These asserts would disappear in the Release builds and the code will keep going resulting on crashes down the road. I haven't experienced any crashes related to this so have been delaying rewriting the error management in this file. But that's totally unrelated to this PR I was just wondering what would be the good way to handle this in the future when we decide to focus effort on fixing the error handling. |
12f6564
to
56473cc
Compare
Good point. I updated the patch to handle that direction too.
I think the |
See ros2/rclpy#96 for checking for a valid return value. |
WIthout the patch the conversion function continue after setting a Python error. With the patch it return
NULL
instead.Ready for review.