[python-win32] Inserting a dictionary of lists into '__main__' of an embedded interpreter

quadric@primenet.com quadric at primenet.com
Fri May 27 23:39:22 CEST 2005


Hi,

I have an application that has an embedded interpreter.  This application 
loads many
DLL's and passes a PyObject *  to each DLL that was gotten from the 
following call:

PyObject * pmod = PyImport_AddModule("__main__") ;


Later, in one of the many DLL's that interact with the embedded 
interpreter, I attempt to insert
a dictionary of lists into the module represented by the pointer 
'pmod'  passed to the DLL from the
main application.

The dictionary of lists is created with the following call:

PyObject * abm_dict = Py_BuildValue( "{s:O,s:O,s:O,s:O,s:O,s:O,s:O,s:O,s:O}" ,
					         "i_list" ,   i_list ,   "l_list"   ,   l_list  , 
"bpl_list"  , bpl_list,
                                                                   "rt_list" 
,  rt_list , "st_list"   ,st_list   ,  "u2_list"  , u2_list ,
                                                                    "t_list" 
, t_list   ,"ot_list"  , ot_list  ,  "plt_list" , plt_list
    					       );

where each item following a quoted string is a PyObject *  created by 
another Py_BuildValue  statement.

After building 'abm_dict' , I attempt to insert it into the embedded 
interpreter with the following call:

PyModule_AddObject( pmod , "abm_dict" , abm_dict );

The application crashes at this point.

Being a bit new to embedded Python, I don't readily see what I'm doing 
wrong.  Could one of you more
experienced guys save me a whole lot of time and point out the obvious to me?

Thanks for your help.










More information about the Python-win32 mailing list