TypeError: unsupported operand type(s) for -: 'Decimal' and 'Decimal'. Why?

Gilbert Fine gilbert.fine at gmail.com
Mon Jul 30 12:48:39 EDT 2007


Thanks. I think I have some direction to do logging, to get more
information about this problem.

It seems that I don't get used to dynamic language yet.

--
Gilbert

On Jul 30, 7:20 pm, Duncan Booth <duncan.bo... at invalid.invalid> wrote:
> Marc 'BlackJack' Rintsch <bj_... at gmx.net> wrote:
>
> > On Mon, 30 Jul 2007 03:36:33 -0700, Gilbert Fine wrote:
>
> >> This is a very strange exception raised from somewhere in our
> >> program. I have no idea how this happen. And don't know how to
> >> reproduce. It just occurs from time to time.
>
> > Maybe different `Decimal`\s?  Here's how to reproduce such a
> > traceback:
>
> <snip>
>
> Or even just one Decimal type but not one which supports subtraction:
>
> >>> class Decimal(object):
>
>      pass
>
> >>> a = Decimal()
> >>> b = Decimal()
> >>> a-b
>
> Traceback (most recent call last):
>   File "<pyshell#4>", line 1, in <module>
>     a-b
> TypeError: unsupported operand type(s) for -: 'Decimal' and 'Decimal'
>
> Another option of course is that Decimal() did support substraction but
> someone deleted it:
>
> >>> from decimal import Decimal
> >>> del Decimal.__sub__
> >>> Decimal()-Decimal()
>
> Traceback (most recent call last):
>   File "<pyshell#15>", line 1, in <module>
>     Decimal()-Decimal()
> TypeError: unsupported operand type(s) for -: 'Decimal' and 'Decimal'





More information about the Python-list mailing list