[Bf-python] info on PyDict_SetItemString()

Gilbert, Joseph T. jgilbert at tigr.ORG
Wed Nov 30 18:03:49 CET 2005


Good catch.

When you put an item into another item it gets a reference to that item.
If you want the list to 'own' the item though you must release your
reference, which is the reason for the decrease in the reference count.

The 'stealing' of references exception is basically a short cut to
releasing your reference manually.

-----Original Message-----
From: bf-python-bounces at projects.blender.org
[mailto:bf-python-bounces at projects.blender.org] On Behalf Of Ken Hughes
Sent: Tuesday, November 29, 2005 10:26 PM
To: Blender Foundation Python list
Subject: [Bf-python] info on PyDict_SetItemString()

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).

Ken
_______________________________________________
Bf-python mailing list
Bf-python at projects.blender.org
http://projects.blender.org/mailman/listinfo/bf-python



More information about the Bf-python mailing list