-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
PyModule_AddIntConstant and PyModule_AddStringConstant can leak #46115
Comments
PyModule_AddObject has somewhat strange reference-counting behavior in As far as I can tell, the correct way to write those functions would be int
PyModule_AddIntConstant(PyObject *m, const char *name, long value)
{
PyObject *o = PyInt_FromLong(value);
if (PyModule_AddObject(m, name, o) == 0)
return 0;
Py_XDECREF(o);
return -1;
} PyModule_AddObject was obviously intended to enable writing the "simple" If there is agreement that my analysis and the proposed fixes are |
Thanks for your analysis! I *think* you are right but I've to study the |
These are meant purely for the convenience of module initialization, and |
I agree that a leak would very rarely occur in practice, but since there |
I don't mind if you like to pursue the issue. I won't invest any time |
Here is a patch, as per description above. |
Committed in r60084. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: