[Bf-committers] CVS Python assert failure on shutdown?

Stephen Swaney sswaney at centurytel.net
Tue Mar 20 19:49:09 CET 2007


On Tue, Mar 20, 2007 at 10:45:09AM -0700, Ken Hughes wrote:
> I *think* I tracked down the cause of this but I'm not sure I understand 
> why it's a problem:
> 
> init_ourImport() has the following code:
> 
>     EXPP_dict_set_item_str( d, "bpy", Main_Init() );
> 
> EXPP_dict_set_item_str() does a Py_DECREF on the third parameter, since 
> adding it to the dictionary creates a new ref.
> 
> If I replace this with:
>     PyDict_SetItemString(d, "bpy", Main_Init() );
> 
> the assert error goes away here.
> 
> I put in some test code and verified that after calling 
> PyDict_SetItemString() the object returned from Main_Init() has two 
> references.
> 
> Can anyone see something I'm missing?

Looks to me like you are on the right track.

PyDict_SetItemString( dict, "name", PyObject*) is a relatively new convenience
 feature in the  C API.  Its purpose is to add a string key to a dict with
out leaking the oh-so-handy PyString_FromString( "name") you need for
PyDict_SetItem().

Our version, EXPP_dict_set_item_str(), is a bit bastardized in that
it decrefs the last param.


comment:  calling Main_Init() twice seems a little hacky

question: I thought we were not using Blender.Main as a module name?

  from Main.c:
      submodule = Py_InitModule3( "Blender.Main", NULL, M_Main_doc );

-- 
Stephen Swaney			
sswaney at centurytel.net



More information about the Bf-committers mailing list