This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients brandtbucher, serhiy.storchaka, vstinner
Date 2020-11-12.12:57:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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:

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:

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.
Date User Action Args
2020-11-12 12:57:32vstinnersetrecipients: + vstinner, serhiy.storchaka, brandtbucher
2020-11-12 12:57:32vstinnersetmessageid: <>
2020-11-12 12:57:32vstinnerlinkissue42327 messages
2020-11-12 12:57:32vstinnercreate