消息 [264393]
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:31 | serhiy.storchaka | 修改 | recipients:
+ serhiy.storchaka, skrah |
| 2016-04-27 19:07:31 | serhiy.storchaka | 修改 | messageid: <1461784051.14.0.60098152504.issue26871@psf.upfronthosting.co.za> |
| 2016-04-27 19:07:31 | serhiy.storchaka | 链接 | issue26871 messages |
| 2016-04-27 19:07:31 | serhiy.storchaka | 创建 | |
|