> On Mar 8, 2025, at 14:57, Oliver Trevor <o...@mit.edu> wrote: > > Hello Gnucash developers, > > I was attempting to use the Gnucash Python bindings to apply payments > to a list of invoices using Customer.ApplyPayment (which maps to > gncOwnerApplyPaymentSecs on the C side), but it gives an error "TypeError: in > method 'gncOwnerApplyPaymentSecs', argument 3 of type 'GList *'" when I > attempt to pass a Python list of lots as the second argument "lots" (third > argument on the C side). > > Looking at how the SWIG bindings were written, I think the issue may be > that there is not a type translator that turns Python lists into GList. > base-typemaps.i has a SWIG type translator on line 269 that converts Python > lists into GSList objects, but as far as I can tell there isn't one that > converts Python lists into GList objects. > > Am I correct that this is an issue, or am I missing how the bindings are > intended to be used? If it's an issue, I could work on a PR to add a type > translator for GList. Also, has anybody ever tried making bindings using > GObject introspection instead of SWIG, since Gnucash's API is already > GLib-based?
Oliver, Looks to like you’re right. There are several SCM List <-> GList* typemaps but only a typemap(out) for Python, not useful for passing arguments into a C function. Go ahead and write a PR. I don’t think anyone has considered GI. While somebody made a start on GI bindings for Guile (https://github.com/spk121/guile-gi) it’s a fairly recent (started in 2019) project and seems to have been abandoned a couple of years ago. Meanwhile on the GnuCash side while it’s true that we have GObject-based classes, their memory management wasn’t done correctly and probably wouldn’t integrate well with GI. Our long-term goal is to reimplement them as C++ objects. Regards, John Ralls
_______________________________________________ gnucash-devel mailing list gnucash-devel@gnucash.org https://lists.gnucash.org/mailman/listinfo/gnucash-devel