[Python-Dev] Inconsistency of PyModule_AddObject()

Berker Peksağ berker.peksag at gmail.com
Wed Apr 27 06:00:29 EDT 2016

On Wed, Apr 27, 2016 at 10:14 AM, Serhiy Storchaka <storchaka at gmail.com> wrote:
> I think that we can resolve this issue by following steps:
> 1. Add a new function PyModule_AddObject2(), that steals a reference even on
> failure.


It would be good to document PyModule_AddObject's current behavior in
3.5+ (already attached a patch).

> 2. Introduce a special macro like PY_SSIZE_T_CLEAN (any suggestions about a
> name?). If it is defined, define PyModule_AddObject as PyModule_AddObject2.
> Define this macro before including Python.h in all CPython modules except
> _json, _io, and _tkinter.


> 3. Make old PyModule_AddObject to emit a warning about possible leak and a
> suggestion to define above macro.


More information about the Python-Dev mailing list