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

Ken Hughes khughes at pacific.edu
Tue Mar 20 19:42:27 CET 2007


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?

OK, I answered my own question.  Py_InitModule3() returns a borrowed 
reference, so decrefing here IS a bad idea.  I'll commit a fix.

Ken



More information about the Bf-committers mailing list