-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Cleanup C++ code #17458
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
Cleanup C++ code #17458
Conversation
The Python side seems to always pass the optional arguments, but technically, these should be initialized before calling `PyArg_ParseTupleAndKeywords` in case they aren't.
A new array is always supplied, so just check that it is the right type/shape. Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
It only returns 0 or 1, so bool hold a better meaning here.
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.
Haven't actually checked this fixes the memleak, but certainly looks correct.
re-milestoned to 3.2.2 as this is in the c++ layer, it is a pretty limited change and the memory leak is pretty bad. |
I actually found more things to cleanup from @anntzer's suggestion, and I think there's another leak on 3.2.x that isn't on master, so for 3.2.2, I think I prefer to manually open that PR. |
fair enough. |
Also, remove extra `(char*)` casts.
These functions all take `const char *` already, or return `char *` directly.
This is a tiny bit more than the image code now, and there are still a bunch of unnecessary |
I also manually confirmed that this fixes the leak. Thanks @QuLogic ! |
PR Summary
Fixes parsing of input arguments, as optional ones should be given a default value (though the Python side may always provide them), and cleanup the ref counts of
output_array
using @anntzer's patch from #15474.Fixes the memory leak due to an extra reference.
PR Checklist