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 xiang.zhang
Recipients xiang.zhang
Date 2017-04-16.16:22:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1492359757.88.0.168735973244.issue30081@psf.upfronthosting.co.za>
In-reply-to
Content
The doc of PyModule_AddObject()[1] states it steals a reference to *value*. But this is only the case when it succeed. On failure the reference is not stolen.

The usages of it across the code base are inconsistent. Some realizes this situation and depends on it: [2]. Some doesn't realize: [3]. Most just assume it always succeeds: [4].

BTW, it seems many modules doesn't release memories well in failure situations in their PyMOD_INIT. Maybe I miss some post-handling procedures?

[1] https://docs.python.org/3/c-api/module.html#c.PyModule_AddObject
[2] https://github.com/python/cpython/blob/master/Python/modsupport.c#L644
[3] https://github.com/python/cpython/blob/master/Modules/gcmodule.c#L1590
[4] https://github.com/python/cpython/blob/master/Modules/_datetimemodule.c#L5799
History
Date User Action Args
2017-04-16 16:22:37xiang.zhangsetrecipients: + xiang.zhang
2017-04-16 16:22:37xiang.zhangsetmessageid: <1492359757.88.0.168735973244.issue30081@psf.upfronthosting.co.za>
2017-04-16 16:22:37xiang.zhanglinkissue30081 messages
2017-04-16 16:22:37xiang.zhangcreate