Author serhiy.storchaka
Recipients serhiy.storchaka, skrah
Date 2016-04-27.19:07:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1461784051.14.0.60098152504.issue26871@psf.upfronthosting.co.za>
In-reply-to
Content
Idiomatic code is

    if (PyModule_AddObject(module, "name", create_new_object()) < 0)
        goto error;

If you already have a reference and need to use it later:

    obj = create_new_object();
    ... /* use obj */
    Py_INCREF();
    if (PyModule_AddObject(module, "name", create_new_object()) < 0)
        goto error;
    ... /* use obj */
    Py_DECREF(obj);

error:
    Py_XDECREF(obj);

Many current code use above idioms, but it doesn't work as expected.

It is almost impossible to write correct code with current behavior. And _decimal.c is not an exception, it has leaks.
History
Date User Action Args
2016-04-27 19:07:31serhiy.storchakasetrecipients: + serhiy.storchaka, skrah
2016-04-27 19:07:31serhiy.storchakasetmessageid: <1461784051.14.0.60098152504.issue26871@psf.upfronthosting.co.za>
2016-04-27 19:07:31serhiy.storchakalinkissue26871 messages
2016-04-27 19:07:31serhiy.storchakacreate