← 输入框|bugs.python.org|刷新

➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 serhiy.storchaka
收信人 serhiy.storchaka, skrah
日期 2016-04-27.19:07:31
SpamBayes Score -1.0
Marked as misclassified 是
Message-id <1461784051.14.0.60098152504.issue26871@psf.upfronthosting.co.za>
In-reply-to
内容
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.
历史
日期 用户 动作 参数
2016-04-27 19:07:31serhiy.storchaka修改recipients: + serhiy.storchaka, skrah
2016-04-27 19:07:31serhiy.storchaka修改messageid: <1461784051.14.0.60098152504.issue26871@psf.upfronthosting.co.za>
2016-04-27 19:07:31serhiy.storchaka链接issue26871 messages
2016-04-27 19:07:31serhiy.storchaka创建