[New-bugs-announce] [issue7633] decimal.py: type conversion in context methods

Stefan Krah report at bugs.python.org
Mon Jan 4 14:01:13 CET 2010

New submission from Stefan Krah <stefan-usenet at bytereef.org>:

I think that context methods should convert arguments regardless of position:

Python 2.7a0 (trunk:76132M, Nov  6 2009, 15:20:35) 
[GCC 4.1.3 20080623 (prerelease) (Ubuntu 4.1.2-23ubuntu3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from decimal import *
>>> c = getcontext()
>>> c.add(8, Decimal(9))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/decimal.py", line 3866, in add
    return a.__add__(b, context=self)
TypeError: wrapper __add__ doesn't take keyword arguments
>>> c.add(Decimal(9), 8)

Also, perhaps c.add(9, 8) should be allowed, too.

messages: 97207
nosy: mark.dickinson, skrah
severity: normal
status: open
title: decimal.py: type conversion in context methods

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list