gnucash stable: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Mon Mar 16 18:07:08 EDT 2026


Updated	 via  https://github.com/Gnucash/gnucash/commit/b521f21a (commit)
	 via  https://github.com/Gnucash/gnucash/commit/33daaf43 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/859f0839 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/556e7b0d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/592b57dd (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e4ec72c9 (commit)
	from  https://github.com/Gnucash/gnucash/commit/be94e9ce (commit)



commit b521f21a1be41596ca929c2f0f019bb4684214b1
Merge: 33daaf4331 859f0839ce
Author: John Ralls <jralls at ceridwen.us>
Date:   Mon Mar 16 15:03:31 2026 -0700

    Merge No-err's 'pr2-return-type-wrapping' into stable.

commit 33daaf433162d61e01ba6218284ba29b6e1c29bb
Merge: be94e9ce41 e4ec72c97c
Author: John Ralls <jralls at ceridwen.us>
Date:   Mon Mar 16 15:01:54 2026 -0700

    Merge No-err's 'pr1-swig-typemap-compat' into stable.

commit 859f0839ce727fef6ac484e753569bd9ee793008
Author: Noah R <Noerr at users.noreply.github.com>
Date:   Fri Mar 6 15:05:30 2026 -0800

    [python-bindings] Add Split wrapping fixes, refactor tests for CI
    
    Add missing gnc_numeric wrapping for two Split methods:
      - GetNoclosingBalance → GncNumeric
      - GetCapGains → GncNumeric
    
    Refactor test_price_and_wrapping.py to create all test data
    programmatically in in-memory sessions, eliminating external data file
    dependencies (pricedb1.gml2, sample1.gnucash) and XML backend
    requirement. All 27 tests now run unconditionally.
    
    Register tests in CI: add imports to runTests.py.in and add
    test_price_and_wrapping.py to CMakeLists.txt dist list.

commit 556e7b0d70e4ff2e0414fb530c3df4236743a29c
Author: Noah R <Noerr at users.noreply.github.com>
Date:   Fri Mar 6 14:18:25 2026 -0800

    [python-bindings] Add get_*_price GncNumeric wrapping, double-wrap protection, and tests
    
    Wrap GncPriceDB.get_latest_price, get_nearest_price, and
    get_nearest_before_price to return GncNumeric instead of raw
    _gnc_numeric SWIG proxies.
    
    Add double-wrap safety in ClassFromFunctions.__init__: if a wrapper
    object is passed as instance=, unwrap it to the underlying SWIG proxy.
    This prevents breakage when callers re-wrap a return value that changed
    from a raw SWIG proxy to a wrapper class, e.g.
    GncNumeric(instance=pricedb.get_latest_price(...)).
    
    New tests:
      TestGetPriceReturnsGncNumeric (4 tests):
        get_latest_price, get_nearest_price, get_nearest_before_price
        return GncNumeric; arithmetic works on the result.
      TestDoubleWrapProtection (4 tests):
        GncNumeric, GncCommodity double-wrap; raw SWIG proxy still works.

commit 592b57ddbb3917399e2b308ed3e8d5108610589e
Author: Noah R <Noerr at users.noreply.github.com>
Date:   Fri Mar 6 12:53:56 2026 -0800

    [python-bindings] Fix missing return-type wrapping and clean up examples
    
    Many Python binding methods silently returned raw SwigPyObject pointers
    instead of proper Python wrapper objects because the methods_return_instance
    dicts were incomplete. This adds the missing entries and activates the
    DeprecationWarning in the SWIG typemap fallback path from PR 1.
    
    Return-type wrapping fixes (gnucash_core.py):
    
      GncPrice (new dict — no wrapping existed before):
        get_commodity → GncCommodity, get_currency → GncCommodity,
        clone → GncPrice, get_value → GncNumeric
    
      GncPriceDB (added to existing dict):
        nth_price → GncPrice, lookup_day_t64 → GncPrice,
        convert_balance_nearest_before_price_t64 → GncNumeric
      GncPriceDB (new list wrapping):
        lookup_latest_any_currency → list[GncPrice],
        lookup_nearest_before_any_currency_t64 → list[GncPrice],
        lookup_nearest_in_time_any_currency_t64 → list[GncPrice]
    
      GncCommodity: obtain_twin → GncCommodity,
                    get_namespace_ds → GncCommodityNamespace
      Account: get_currency_or_parent → GncCommodity,
               GetLotList → list[GncLot]
      GncLot: get_split_list → list[Split]
    
    Example script cleanup:
      Remove type(x).__name__ == 'SwigPyObject' workarounds from
      gnc_convenience.py, gncinvoicefkt.py, str_methods.py — these are
      no longer needed now that methods return proper wrapper objects.
    
    SWIG typemap (gnucash_core.i):
      Activate DeprecationWarning on the .instance fallback path, replacing
      the TODO placeholder from the typemap compatibility layer commit.
    
    New test file (test_price_and_wrapping.py):
      18 tests covering all wrapping fixes and typemap compatibility,
      using in-repo test data (pricedb1.gml2, sample1.gnucash).
      Tests auto-skip when XML backend is unavailable.

commit e4ec72c97c80559db9ef4aa7d07eea37a9021dd5
Author: Noah R <Noerr at users.noreply.github.com>
Date:   Fri Mar 6 12:35:35 2026 -0800

    [python-bindings] Add SWIG typemap compatibility layer for wrapper objects
    
    Add GNC_ACCEPT_WRAPPER macro that generates %typemap(in) entries for
    all core engine and business pointer types. These typemaps accept both
    raw SWIG pointers (zero-overhead fast path) and ClassFromFunctions
    wrapper objects (fallback path that extracts .instance).
    
    This is pure infrastructure for an upcoming change that fixes missing
    return-type wrapping in gnucash_core.py. Once methods like
    GncPriceDB.nth_price() return proper GncPrice wrapper objects instead
    of raw SwigPyObjects, existing code that passes those objects to
    gnucash_core_c C functions would break. These typemaps prevent that
    breakage: the C functions transparently unwrap the .instance pointer.
    
    Covered types:
      Core: Account, Split, Transaction, GNCLot, gnc_commodity,
            gnc_commodity_namespace, gnc_commodity_table, GNCPrice,
            GNCPriceDB, QofBook, QofSession, GncGUID
      Business: GncCustomer, GncEmployee, GncVendor, GncJob,
                GncAddress, GncBillTerm, GncTaxTable, GncInvoice, GncEntry
    
    GncOwner is excluded — it has its own custom type-dispatching typemaps.



Summary of changes:
 bindings/python/example_scripts/gnc_convenience.py |  20 -
 bindings/python/example_scripts/gncinvoicefkt.py   |   5 -
 bindings/python/example_scripts/str_methods.py     |   2 -
 bindings/python/function_class.py                  |   9 +-
 bindings/python/gnucash_core.i                     |  76 ++++
 bindings/python/gnucash_core.py                    |  39 +-
 bindings/python/tests/CMakeLists.txt               |   3 +-
 bindings/python/tests/runTests.py.in               |  11 +
 bindings/python/tests/test_price_and_wrapping.py   | 457 +++++++++++++++++++++
 9 files changed, 588 insertions(+), 34 deletions(-)
 create mode 100644 bindings/python/tests/test_price_and_wrapping.py



More information about the gnucash-patches mailing list