[Python-Dev] Inconsistency of PyModule_AddObject()

Random832 random832 at fastmail.com
Thu Apr 28 09:28:46 EDT 2016


On Thu, Apr 28, 2016, at 05:05, Stefan Krah wrote:
> $ valgrind --suppressions=Misc/valgrind-python.supp ./python -c "import
> decimal"
> 
> [...]
> ==16945== LEAK SUMMARY:
> ==16945==    definitely lost: 0 bytes in 0 blocks
>              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Well, the obvious flaw with your test case is that a reference is
retained forever in the C static variable basic_context_template.

Now, it is arguable that this may be a reasonably common pattern, and
that this doesn't actually constitute misuse of the API (the reference
count will be wrong, but the object itself is immortal anyway, so it
doesn't matter if it's 2 or 1 since it can't be 0 even with correct
usage)


More information about the Python-Dev mailing list