Python bindings: Account.getName() raises TypeError

John Ralls jralls at ceridwen.us
Sun Mar 16 15:38:25 EDT 2014


On Mar 16, 2014, at 12:08 PM, Felix Schwarz <felix.schwarz at oss.schwarz.eu> wrote:

> Hey,
> 
> after switching to gnucash 2.6 I noticed that at least some of the Python
> methods are broken [1]. A call to Account.getName() raises a TypeError but
> unfortunately the error message is not helpful to me (as I never used swig
> before):
> TypeError: in method 'xaccAccountGetName', argument 1 of type 'Account const *'
> 
> I tried to pin down the issue via bisecting but the problem was that many
> older version don't build for me because of broken svn references. Probably
> the error was introduced very early after 2.4, I noticed the same behavior in
> 2.5.3 (the first 2.5 version I was able to build without hassle).
> 
> I noticed that most core developers don't use the Python bindings themself so
> I'm looking for pointers where I should start looking to fix the error.
> - How would you tackle the problem? More bisecting efforts? Runtime debugging?
> - Should I try to get acquainted with swig?
> - Is it possible the my issue is just Fedora-related (e.g. due to some bad
>  library version)?
> - Any hints what could have caused the issue (e.g. bigger swig related
>  changes, core refactorings)?

The signature of xaccAccountGetName is const char* xaccAccountGetName (const Account *); the const was added in 2005. A "const Account *" is not the same as an "Account const *": The former means that the contents of the pointer won't change, the latter means that the pointer itself won't change (see https://www.cs.bu.edu/teaching/cpp/const/).

Somewhere in the SWIG-generated Python-to-C translation code the argument type is wrong, but it's not directly in the stack trace from Python. It's more likely due to a change in SWIG than to a change in GnuCash.

Regards,
John Ralls




More information about the gnucash-devel mailing list