Neal, Why did you suggest that PyAST_FromNode returns PyTypeObject*? I can't see why type objects are much used in the AST, unless I'm missing something essential.
Anyway, I started converting ast.c (two functions only), and noticed that there is a convention to have nested variables referring to fresh memory (e.g. inside switch statements). I started changing these to have all variables at the toplevel. Then, in either success or failure, you have to release all of them. Unfortunately, sometimes in failure, an additional function is called, which isn't called in success. So I added a success: label. Also, it is somewhat inconvenient that PyList_SET_ITEM steals references. Currently, I INCREF the objects added to the list (as the success: label will DECREF them); alternatively, clearing the pointer to NULL might also be appropriate. Perhaps we could have a STEAL_ITEM macro inside ast.c: #define STEAL_ITEM(list,index,variable) \ do{PyList_SET_ITEM(list,index,variable);variable=NULL;}while(0) Regards, Martin _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com