Repository navigation
Fix Amount __sub__ and __eq__ referencing removed currency_type - #424
harshajv7981 wants to merge 1 commit into
Conversation
Commit 48562de renamed the attribute to ccy_name but left these two references behind, so subtracting or comparing Amounts raised AttributeError.
|
The failing In case it's useful, the cause: 5710283 added the |
Problem
Amount(100, "CAD") - Amount(40, "CAD")andAmount(1, "CAD") == Amount(1, "CAD")raiseAttributeError: 'Amount' object has no attribute 'currency_type'. Commit 48562de renamed the attribute toccy_namebut__sub__and__eq__still readcurrency_type.Change
Use
ccy_namein those two places, matching__add__,__truediv__and_check_currency. Two identifiers changed, nothing else.Verification
tests/unit/test_FinAmount.py::test_amount_sub_and_eqfails before this change (theAttributeErrorabove) and passes after.tests/unit/test_FinAmount.py: 2 passed.Amountisn't used elsewhere in the package.I found this with patchwork, an automated code-audit tool I run, and verified the reproduction test in an isolated sandbox. If tool-assisted reports aren't welcome here, let me know and I won't send more.