gnucash stable: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Fri Sep 25 17:38:55 EDT 2026


Updated	 via  https://github.com/Gnucash/gnucash/commit/fbcb9f5e (commit)
	 via  https://github.com/Gnucash/gnucash/commit/89448ffd (commit)
	from  https://github.com/Gnucash/gnucash/commit/973a64ce (commit)



commit fbcb9f5e756321a161a1ecf478a81d866b1d03a8
Merge: 973a64ceda 89448ffd34
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Sep 25 14:38:24 2026 -0700

    Merge Noah Noerr's 'bug799796-price-example-getvalue' into stable.

commit 89448ffd3420ae563a4fece75b9e6ec9a9db5927
Author: Noerr <Noerr at users.noreply.github.com>
Date:   Wed Sep 23 01:05:21 2026 -0700

    [bindings/python] Fix and modernize the price example scripts (Bug 799796)
    
    PR #2187 made GncPrice.get_value() return a GncNumeric wrapper and clone() a
    fully wrapped GncPrice. The price example scripts still used the pre-5.15 raw
    _gnc_numeric idiom and broke -- reported as Bug 799796 (cloned prices silently
    kept the original value).
    
    Example scripts (bindings/python/example_scripts/):
    
    * quotes_historic.py -- reworked to the modern idiom; it now actually runs on
      5.x (it had further latent breakage beyond the reported one):
      - Construct each price directly with GncPrice(book) + setters instead of
        cloning an existing price, so the script no longer needs a pre-existing
        price in the book. Look the pricing currency (USD) up from the commodity
        table rather than deriving it from a split.
      - Build the value with the double->GncNumeric constructor at GnuCash's
        standard price precision -- the pricing currency's SCU * COMMODITY_DENOM_MULT
        rounded HALF_UP (gnc-pricedb.h "Price policy") -- dropping the
        Fraction.from_float().limit_denominator(100000) dance and its import.
      - Set the source with the PriceSource enum -- set_source(PriceSource.FINANCE_QUOTE)
        (the enum added in #2317). The original set_source("Finance::Quotes::Historic")
        passed a string to what has been an enum setter since 2.6, which raises
        TypeError on modern bindings.
      - Open with Session(url), which defaults to SESSION_NORMAL_OPEN. The old
        Session(url, True, False, False) passed the deprecated ignore_lock=True,
        silently bypassing the book's lock file.
    
    * priceDB_test.py, price_database_example.py -- num/denom are methods now, so
      read v.num() / v.denom().
    
    Prevent silent recurrence (gnucash_core.py):
    The write path failed *silently*, which is how this slipped through review and
    CI. num/denom are read-only accessor methods, so assigning to them merely
    shadows the method and changes nothing. Add a GncNumeric.__setattr__ that raises
    AttributeError on assignment to num/denom, pointing at the correct idiom
    GncNumeric(num, denom).
    
    Test (bindings/python/tests/test_numeric.py):
    New test_num_denom_read_only covering the guard. It needs no backend, so it runs
    in the existing python-bindings CTest on all platforms.
    
    The wiki page Stocks/get_prices, which the reporter copied from, is being
    updated separately.



Summary of changes:
 bindings/python/example_scripts/priceDB_test.py    |  4 +-
 .../example_scripts/price_database_example.py      |  2 +-
 bindings/python/example_scripts/quotes_historic.py | 52 +++++++++-------------
 bindings/python/gnucash_core.py                    | 10 +++++
 bindings/python/tests/test_numeric.py              | 13 ++++++
 5 files changed, 48 insertions(+), 33 deletions(-)



More information about the gnucash-patches mailing list