[Python-Dev] Inconsistency of PyModule_AddObject() (original) (raw)

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 PyModuleAddObject2(), that steals a reference even on failure.

+1

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

2. Introduce a special macro like PYSSIZETCLEAN (any suggestions about a name?). If it is defined, define PyModuleAddObject as PyModuleAddObject2. Define this macro before including Python.h in all CPython modules except json, io, and tkinter.

+1

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

+0



More information about the Python-Dev mailing list