Message264393
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. |
|
Date |
User |
Action |
Args |
2016-04-27 19:07:31 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, skrah |
2016-04-27 19:07:31 | serhiy.storchaka | set | messageid: <1461784051.14.0.60098152504.issue26871@psf.upfronthosting.co.za> |
2016-04-27 19:07:31 | serhiy.storchaka | link | issue26871 messages |
2016-04-27 19:07:31 | serhiy.storchaka | create | |
|