Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
gh-86493: Use PyModule_Add() instead of PyModule_AddObjectRef()#106860
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
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
int rc = PyModule_AddObjectRef(mod, "WITH_PYMALLOC", v); | ||
Py_DECREF(v); | ||
if (rc < 0) { | ||
if (PyModule_AddObjectRef(mod, "WITH_PYMALLOC", v) < 0) { |
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.
Was this purposefully not converted toPyModule_Add()
?
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.
Yes,PyModule_AddObjectRef()
is more fitting here. But the old code was complicated without need.
Uh oh!
There was an error while loading.Please reload this page.
If
PyModule_AddObjectRef()
followed byPy_DECREF()
of the added value, the code can be simplified by usingPyModule_Add()
which was designed specially for such cases.