On Wed, Mar 25, 2015 at 8:26 AM, Grant Edwards <invalid@invalid.invalid> wrote:
> On 2015-03-25, Larry Martell <larry.mart...@gmail.com> wrote:
>> I have an app that works with 2.6, but in 2.7 it is failing. I traced
>> it down to an issue with decimal.Decimal being passed a value of 0.0.
>> It 2.6 this is fine, but in 2.7 it throws an exception:
>>
>> TypeError: Cannot convert float to Decimal.  First convert the float to a 
>> string
>>
>> This is easy enough to deal with, but I find it odd. Is this a known issue?
>
> $ python
> Python 2.7.9 (default, Jan  2 2015, 09:51:10)
> [GCC 4.8.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import decimal
>>>> decimal.Decimal(0)
> Decimal('0')
>>>> decimal.Decimal(0.0)
> Decimal('0')
>>>> decimal.Decimal('0')

I'm sorry, I missed typed. It works in 2.7, but not in 2.6:


]$ python
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import decimal
>>> decimal.Decimal(0.0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/decimal.py", line 649, in __new__
    "First convert the float to a string")
TypeError: Cannot convert float to Decimal.  First convert the float to a string
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to