STINNER Victor <vstin...@python.org> added the comment:
Oh, I just rejected PR 17298. Copy of my message: --- I added PyModule_AddObjectRef() which uses strong references, rather than only stealing a reference on success. I also enhanced the documentation to show concrete examples: https://docs.python.org/dev/c-api/module.html#c.PyModule_AddObjectRef I modified a few extension to use PyModule_AddObjectRef(). Sometimes, PyModule_AddObject() is more appropriate. Sometimes, PyModule_AddObjectRef() is more appropriate. Both functions are relevant, and I don't see a clear winner. I agree than fixing existing code is painful, but I hope that new code using mostly PyModule_AddObjectRef() would be simpler to review. I'm not sure that it's simpler to write new code using PyModule_AddObjectRef(), since you might need more Py_DECREF() calls. My intent is to have more "regular" code about reference counting. See also: https://bugs.python.org/issue42294 Since you wrote that this API is a band aid on a broken API, I consider that you are fine with rejecting it and move on to the new PyModule_AddObjectRef(). Anyway, thanks for you attempt to make the C API less broken :-) --- I added PyModule_AddObjectRef() in bpo-163574. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42327> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com