GNOME Bugzilla – Bug 796137
query.search_for outputs critical qof.object errors and prevents queries being run
Last modified: 2018-06-30 00:10:18 UTC
Created attachment 372070 [details] Example of issue Hi there, In the master version of Gnucash the query.search_for() function currently returns the following output: E.g. the following code: query = gnucash.Query() query.search_for(gnucash.gnucash_core_c.GNC_ID_INVOICE) query.set_book(session.book) query.run() Produces the following on the query.search_for line: * 08:41:59 WARN <qof.class> [qof_class_get_parameter()] no object of type К * 08:41:59 WARN <qof.class> [qof_class_get_parameter()] no object of type ▒ ▒ * 08:41:59 CRIT <qof.object> [qof_object_foreach()] No object of type ▒ ▒ The query.run line then produces no results. I believe this issue was introduced in the migration to Python3 - while gnucash.gnucash_core_c.GNC_ID_INVOICE appears to be the correct representation of 'gncInvoice' which is required to be passed though to qof_query_search_for, this function expects it to be a char array, but the Python bindings/SWIG seems to convert it to a Python 3 unicode string somehow causing the errors. Passing a string though instead of the constant e.g.: query.search_for('gncInvoice') Gives the same result Attepting to pass a byte array though e.g.: query.search_for(b'gncInvoice') Gives an incorrect type error in the swig generated code. I have a feeling a typemap needs to be added to convert from the Python3 string to the char array or something similar but I've been unable to get this to work. Please find a complete example (which assumes certain MySQL credentials) of the issue which will fail when run in Python 3 (it will work when run in an older version built with Python 2 bindings).
GnuCash bug tracking has moved to a new Bugzilla host. The new URL for this bug is https://bugs.gnucash.org/show_bug.cgi?id=796137. Please continue processing the bug there and please update any external references or bookmarks.