After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 726430 - Python: account.getName() raises TypeError
Python: account.getName() raises TypeError
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Python Bindings
2.6.2
Other Linux
: Normal normal
: ---
Assigned To: gnucash-core-maint
gnucash-core-maint
Depends on:
Blocks:
 
 
Reported: 2014-03-15 18:45 UTC by Felix Schwarz
Modified: 2018-06-29 23:28 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Felix Schwarz 2014-03-15 18:45:02 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):
  • File "new_book_with_opening_balances.py", line 356 in <module>
    main()
  • File "new_book_with_opening_balances.py", line 317 in main
    ACCOUNT_TYPES_TO_OPEN
  • File "new_book_with_opening_balances.py", line 191 in recursivly_build_account_tree
    getattr(original_account, 'Get' + attribute)() )
  • File "/usr/lib64/python2.7/site-packages/gnucash/function_class.py", line 91 in method_function
    *process_list_convert_to_instance(meth_func_args) )
  • File "/usr/lib64/python2.7/site-packages/gnucash/gnucash_core_c.py", line 543 in xaccAccountGetName
    return _gnucash_core_c.xaccAccountGetName(*args)
TypeError: in method 'xaccAccountGetName', argument 1 of type 'Account const *'

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
Comment 1 Geert Janssens 2014-03-19 16:38:03 UTC
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.
Comment 2 John Ralls 2018-06-29 23:28:22 UTC
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.