<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hello John,</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
     I have submitted a PR (<a href="https://github.com/Gnucash/gnucash/pull/2066" id="LPlnk951583">https://github.com/Gnucash/gnucash/pull/2066</a>). I added type translators for all the types that were supported by the typemap(out) for GList but have only
 tested with lists of GncLot objects, as I am not sure where to find existing C functions that take some of the other types of lists. This at least fixes the issue with Customer.ApplyPayment not working at all from Python.</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks,</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Oliver Trevor</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> John Ralls <jralls@ceridwen.us><br>
<b>Sent:</b> Saturday, March 8, 2025 11:26 PM<br>
<b>To:</b> Oliver Trevor <olt@mit.edu><br>
<b>Cc:</b> gnucash-devel@gnucash.org <gnucash-devel@gnucash.org><br>
<b>Subject:</b> Re: Issues with GList Arguments in Python Bindings?</font>
<div> </div>
</div>
<div style="line-break:after-white-space"><br id="x_lineBreakAtBeginningOfMessage">
<div><br>
<blockquote type="cite">
<div>On Mar 8, 2025, at 14:57, Oliver Trevor <olt@mit.edu> wrote:</div>
<br class="x_Apple-interchange-newline">
<div>
<div class="x_elementToProof" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt">
Hello Gnucash developers,</div>
<div class="x_elementToProof" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt">
<br>
</div>
<div class="x_elementToProof" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt">
      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).</div>
<div class="x_elementToProof" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt">
<br>
</div>
<div class="x_elementToProof" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt">
     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.</div>
<div class="x_elementToProof" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt">
<br>
</div>
<div class="x_elementToProof" style="font-style:normal; font-variant-caps:normal; font-weight:400; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt">
     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?</div>
</div>
</blockquote>
<br>
</div>
<div>Oliver,</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>I don’t think anyone has considered GI. While somebody made a start on GI bindings for Guile (<a href="https://github.com/spk121/guile-gi">https://github.com/spk121/guile-gi</a>) 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.</div>
<div><br>
</div>
<div>Regards,</div>
<div>John Ralls</div>
<br>
</div>
</body>
</html>