Skip to content

builtins.round fails if passed a decimal #501

Closed
@tpict

Description

@tpict
>>> round(Decimal('0.5'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".venv/lib/python2.7/site-packages/future/builtins/newround.py", line 42, in newround
    d = Decimal.from_float(number).quantize(exponent,
  File "/Users/tpict/.asdf/installs/python/2.7.16/lib/python2.7/decimal.py", line 690, in from_float
    n, d = abs(f).as_integer_ratio()
AttributeError: 'Decimal' object has no attribute 'as_integer_ratio'

The newround function doesn't check if the input is of type Decimal before trying to convert it to one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions