GNOME Bugzilla – Bug 726430
Python: account.getName() raises TypeError
Last modified: 2018-06-29 23:28:22 UTC
When I run the provided example script "new_book_with_opening_balances.py" it always aborts with a type error: $ python new_book_with_opening_balances.py test.xml.gnucash xml:///home/fs/Desktop/test.sqlite.gnucash * 19:21:27 WARN <gnc.backend.dbi> [gnc_module_init_backend_dbi()] No DBD drivers found Traceback (most recent call last):
+ Trace 233345
main()
ACCOUNT_TYPES_TO_OPEN
getattr(original_account, 'Get' + attribute)() )
*process_list_convert_to_instance(meth_func_args) )
return _gnucash_core_c.xaccAccountGetName(*args)
The problem is likely independent of any specific data file (I just created a new one). Also similar code did work for me in gnucash 2.4 so it's likely a regression. some system info: gnucash-2.6.1-1.fc20.x86_64 python-2.7.5-11.fc20.x86_64
Thank you for your report. As I also mentioned on the mailing list I found the cause of the issue and fixed it in https://github.com/Gnucash/gnucash/commit/2215e382 Account functions return Accounts or lists of Accounts now instead of SwigPyObjects. So it's no longer necessary to get the Account instance out of the SwigPyObject. And trying to do so on the returned Account object is even an error - the TypeError you got. I did fix one additional error in the script: it couldn't handle accounts in non-currency commodities. That should work properly now as well.
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=726430. Please update any external references or bookmarks.