Title: Inconsistent handling of failure of PyModule_AddObject
Type: behavior Stage: resolved
Components: Versions:
Status: closed Resolution: duplicate
Dependencies: Superseder: Change weird behavior of PyModule_AddObject()
View: 26871
Assigned To: Nosy List: serhiy.storchaka, xiang.zhang
Priority: normal Keywords:

Created on 2017-04-16 16:22 by xiang.zhang, last changed 2017-04-16 16:44 by xiang.zhang. This issue is now closed.

Messages (3)
msg291750 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-04-16 16:22
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?

msg291751 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-04-16 16:33
This is a duplicate of issue26868 and issue26871. There is also a thread on Python-Dev.
msg291753 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-04-16 16:44
Ohh, I am not alone. :-)
Date User Action Args
2017-04-16 16:44:28xiang.zhangsetstatus: open -> closed
resolution: duplicate
messages: + msg291753

superseder: Change weird behavior of PyModule_AddObject()
stage: resolved
2017-04-16 16:33:37serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg291751
2017-04-16 16:22:37xiang.zhangcreate