In attempting to use qof query to look up budgets I have come across an issue in base-typemaps.i for which Im not sure would be the approved way to fix.
The first python Query class usage to attempt to return budgets returned a list of gnc_monetary types, yet it should have been GncBudget. (note the only implementation involved was in python setting up the query and calling the query run function). This appears to be a problem in the swig out typemap in base-typemaps.i for GList type structures. This typemap is defined differently for python versus scheme - here Im specifically dealing with the Python version. Currently there is a test for some specific list element data types which then types each data element. However, there is a special test for MonetaryList which maps the gnc_monetary type. else if ($1_descriptor == $descriptor(MonetaryList *)) PyList_Append(list, SWIG_NewPointerObj(data, $descriptor(gnc_monetary *), 0)); The problem found returning budgets is that this matches any arbitrary GList whose type is not defined in the previous else if components of the if structure, hence a list of budgets is returned as a list of gnc_monetary type. So far Ive created a separate out typemap for MonetaryList specifically which assumes the elements of a MonetaryList are all gnc_monetary type. (Its not clear to me its possible for it to be anything else). I removed the above test from the more generic GList out typemap and added a specific check for data elements of the swig budget type similar the current style. Question is why is this routine defined for various specific types eg CommodityList *, SplitList *, AccountList *, LotList *, PriceList *, EntryList * where it seems to me the elements must always be of a specific type. Also, returning a void type for untested element types would seem to me to be better than returning a wrong type for a generic GList (it may be possible to re-map the swig void type in python later). David _______________________________________________ gnucash-devel mailing list gnucash-devel@gnucash.org https://lists.gnucash.org/mailman/listinfo/gnucash-devel