prob. creating deeply nested structures in Py/c api

Ori Y geensys at yahoo.com
Sat Feb 28 08:41:47 EST 2004


Hi , i'm having some difficulties regarding using the Python/c api.
 
I'm trying to bulid a deeply nested datastructure (i.e dict within a dict or list within a dict)
Building the data stracture seems ok on interperter, but after few calls to the method
returning the structure, and aft applying the Ctrl+D to exit interperter
 i receive a 'segmentation fault'. ?#
Further more when calling the program from python i receive the dictionary as a string!
"{foo: {1:'blah, 2:'boo'}, bar:1}"     (i have a feeling these problems are related).
 
I'm using python 2.3 on a RH9 Linux machine.
Advise would be very much appriciated.
 
Here is a shorter example of the consept  i'm trying to do :
 
static *PyObject blah (something)
{
  PyObject *dict1;
  PyObject *dict2;
  long x;
 
 dict1 = PyDict_New();
 dict2 = PyDict_New();
 x = 1;
 
PyDict_SetItem(dict1, PyString_FromString("foo"),PyInt_FromLong(x)); //setting first dict
 
//setting dict1 in dict2 and returning dict2

PyDict_SetItem(dict2, PyString_FromString("blah"),dict1); 
// expected {blah:{foo:1}}
 
 
 



---------------------------------
Do you Yahoo!?
Get better spam protection with Yahoo! Mail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20040228/ca511e69/attachment.html>


More information about the Python-list mailing list