Title: decimal differs between pure Python and C implementations
Type: Stage: resolved
Components: Library (Lib) Versions:
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: facundobatista, hauntsaninja, mark.dickinson, rhettinger, skrah
Priority: normal Keywords:

Created on 2020-02-22 01:18 by hauntsaninja, last changed 2020-02-22 07:57 by rhettinger. This issue is now closed.

Messages (4)
msg362443 - (view) Author: Shantanu (hauntsaninja) * Date: 2020-02-22 01:18
The dunder methods on decimal.Decimal accept an extra context argument in the pure Python version which the C version does not (violating PEP 399).

This came up in, where Sebastian provided the following summary of the issue:
Python 3.8.1 (default, Jan 14 2020, 19:41:43) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from _decimal import Decimal as CDecimal
>>> from _pydecimal import Decimal as PyDecimal
>>> PyDecimal(1).__abs__(None)
>>> CDecimal(1).__abs__(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: expected 0 arguments, got 1
msg362452 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-02-22 07:33
I wouldn't worry about this.  The context argument for the dunder methods isn't part of the public API.  It is just an internal implementation detail that was necessary for the Python implementation but would make no sense at all for the C implementation.
msg362453 - (view) Author: Shantanu (hauntsaninja) * Date: 2020-02-22 07:45
Sounds good, thought I'd check! :-) Definitely looks annoying to remove from the Python version too.
msg362454 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-02-22 07:57
Thanks for double checking.
Date User Action Args
2020-02-22 07:57:38rhettingersetstatus: open -> closed
resolution: not a bug
messages: + msg362454

stage: resolved
2020-02-22 07:45:45hauntsaninjasetmessages: + msg362453
2020-02-22 07:33:57rhettingersetmessages: + msg362452
2020-02-22 02:34:55xtreaksetnosy: + rhettinger, facundobatista, mark.dickinson, skrah
2020-02-22 01:18:00hauntsaninjacreate