rp2: Python 3.10: TypeError: __add__() got an unexpected keyword argument 'context'

Running the example i’m getting this error (tested with Python3.9 and Python3.10)

 $ rp2_us -m fifo -o output -p crypto_example_ crypto_example.config crypto_example.ods
INFO: Country: us
INFO: Accounting Method: fifo
INFO: Configuration file: crypto_example.config
INFO: Input file: crypto_example.ods
INFO: Processing BTC
ERROR: Fatal exception occurred:
Traceback (most recent call last):
  File "/home/rndstr/venv/lib/python3.9/site-packages/rp2/rp2_main.py", line 93, in _rp2_main_internal
    input_data: InputData = parse_ods(configuration=configuration, asset=asset, input_file_handle=input_file_handle)
  File "/home/rndstr/venv/lib/python3.9/site-packages/rp2/ods_parser.py", line 128, in parse_ods
    _create_and_process_transaction(
  File "/home/rndstr/venv/lib/python3.9/site-packages/rp2/ods_parser.py", line 168, in _create_and_process_transaction
    transaction: AbstractTransaction = _create_transaction(configuration, current_table_type, internal_id, row_values)
  File "/home/rndstr/venv/lib/python3.9/site-packages/rp2/ods_parser.py", line 277, in _create_transaction
    transaction = InTransaction(**argument_pack)
  File "/home/rndstr/venv/lib/python3.9/site-packages/rp2/in_transaction.py", line 52, in __init__
    super().__init__(configuration, timestamp, asset, transaction_type, spot_price, internal_id, unique_id, notes)
  File "/home/rndstr/venv/lib/python3.9/site-packages/rp2/abstract_transaction.py", line 41, in __init__
    self.__spot_price: RP2Decimal = configuration.type_check_positive_decimal("spot_price", spot_price)
  File "/home/rndstr/venv/lib/python3.9/site-packages/rp2/configuration.py", line 276, in type_check_positive_decimal
    if result < ZERO:
  File "/home/rndstr/venv/lib/python3.9/site-packages/rp2/rp2_decimal.py", line 59, in __lt__
    return not self.__ge__(other)
  File "/home/rndstr/venv/lib/python3.9/site-packages/rp2/rp2_decimal.py", line 48, in __ge__
    return (self - other).quantize(CRYPTO_DECIMAL_MASK).__ge__(ZERO)
  File "/home/rndstr/venv/lib/python3.9/site-packages/rp2/rp2_decimal.py", line 69, in __sub__
    return RP2Decimal(Decimal.__sub__(self, other))
  File "/usr/lib/python3.9/_pydecimal.py", line 1257, in __sub__
    return self.__add__(other.copy_negate(), context=context)
TypeError: __add__() got an unexpected keyword argument 'context'
INFO: Log file: ./log/rp2_2022_04_10_15_52_55_045185.log
INFO: Generated output directory: output
INFO: Done

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Good idea. If you also want to submit a PR to add the dependency for RP2 I’ll approve it.

Fantastic! Thanks for the good detective work 😃

I tried with Python 3.10 on my personal machine and I couldn’t repro this problem. I also added Python 3.10 to continuous integration on Windows, Mac and Linux and it all works well (see https://github.com/eprbell/rp2/commit/0d7b01a7649d8f50c65c28c85e323e92ad5ce2d5). I think the issue you are seeing might be due to some specific problem with your Python installation.