[GNC-dev] Python bindings: Exception when calling GetDatePosted on unposted invoice

Frank Oltmanns frank.oltmanns at gmail.com
Wed Feb 6 13:19:57 EST 2019


Dear all,

I'm using the python bindings from GnuCash 3.3 (debian package from sid).
When calling GetDatePosted() on an unposted invoice a get the following
exception:
ValueError: month must be in 1..12

This function is used in the example scripts that are part of GnuCash
(gnucash_simple.py). In this example the exception is not caught but
instead there is a check if the date is 1970-01-01 (of course it never
comes to the check because of the exception).

This is the stack trace:
  File "/path/to/gnucash_helper/gnucash_simple.py", line 161, in
invoiceToDict
    if invoice.GetDatePosted().strftime('%Y-%m-%d') == '1970-01-01':
  File "/usr/lib/python3/dist-packages/gnucash/function_class.py", line 91,
in method_function
    *process_list_convert_to_instance(meth_func_args) )
  File "/usr/lib/python3/dist-packages/gnucash/gnucash_core_c.py", line
3919, in gncInvoiceGetDatePosted
    return _gnucash_core_c.gncInvoiceGetDatePosted(invoice)

Is this something that has changed since GnuCash 2.6 and was
gnucash_simple.py has not been updated accordingly? Or is this an error in
_gnucash_core_c.gncInvoiceGetDatePosted()?

I mean, should I design my application to expect the exception or should
this be fixed in the python bindings. If it is the latter, I'd appreciate
any pointers on where I should start looking.

Best regards
  Frank


More information about the gnucash-devel mailing list