[Bf-python] info on PyDict_SetItemString()
Martin Poirier
theeth at yahoo.com
Wed Nov 30 04:42:04 CET 2005
--- Ken Hughes <khughes at pacific.edu> wrote:
> A heads-up for those who didn't know it (including
> me, until about 10
> minutes ago):
>
> PyDict_SetItemString() [ and probably
> PyDict_SetItem() ] make a new
> reference to the value inserted into the dictionary,
> so make sure you
> Py_DECREF() the object afterward if necessary. I've
> found a number of
> places where we're not doing so (and plan to go
> through tonight an
> tomorrow to correct if possible).
IIRC, the only methods that steal a reference are
PyTuple_SetItem and PyList_SetItem. Going through the
Sequence protocol with PySequence_SetItem does NOT
steal one, as does all the dictionnary/mapping
methods.
Thanks for the heads up though. Ref counting is always
fun. :)
Martin
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
More information about the Bf-python
mailing list