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 796137 - query.search_for outputs critical qof.object errors and prevents queries being run
query.search_for outputs critical qof.object errors and prevents queries bein...
Status: RESOLVED OBSOLETE
Product: GnuCash
Classification: Other
Component: Python Bindings
git-master
Other Linux
: Normal normal
: future
Assigned To: gnucash-core-maint
gnucash-core-maint
Depends on:
Blocks:
 
 
Reported: 2018-05-15 12:55 UTC by Tom Lofts
Modified: 2018-06-30 00:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Example of issue (578 bytes, text/plain)
2018-05-15 12:55 UTC, Tom Lofts
Details

Description Tom Lofts 2018-05-15 12:55:10 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).
Comment 1 John Ralls 2018-06-30 00:10:18 UTC
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.