Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builtins.round fails if passed a decimal #501

Closed
tpict opened this issue Sep 20, 2019 · 3 comments · Fixed by #517
Closed

builtins.round fails if passed a decimal #501

tpict opened this issue Sep 20, 2019 · 3 comments · Fixed by #517

Comments

@tpict
Copy link
Contributor

tpict commented Sep 20, 2019

>>> 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.

@jmadler
Copy link
Contributor

jmadler commented Oct 17, 2019

Can you submit a bugfix please? I'll include it in a release in the next few days.

@tpict
Copy link
Contributor Author

tpict commented Oct 22, 2019

Done!

@jmadler
Copy link
Contributor

jmadler commented Oct 24, 2019

Thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants