[Beem-0.20.6] DivisionByZero Error in RC manabar lookup
Project Information
- Repository: https://github.com/holgern/beem
- Project Name: Beem
- Publisher: @holger80
A GitHub issue was created and could be fixed with a PR.
Expected behavior
Account.get_rc_manabar()
should return the current RC mana state of an Account
Actual behavior
Account.get_rc_manabar()
may raise a ZeroDivisionError
exception if the corresponding account has a max_rc
bandwidth of 0.
How to reproduce
from beem.account import Account
a = Account('a-pile-of-steem')
print(a.get_rc_manabar())
Traceback (most recent call last):
File "bug_rc.py", line 3, in <module>
print(a.get_rc_manabar())
File "/usr/local/lib/python3.6/site-packages/beem/account.py", line 241, in get_rc_manabar
current_pct = current_mana / max_mana * 100
ZeroDivisionError: division by zero
Environment
# beempy --version
beempy, version 0.20.6
# python --version
Python 3.6.6
Fix
The division by zero error was triggered in the calculation of the relative RC balance as the current value over its maximum. The given account has a maximum RC balance of 0. By checking for non-zero divisors before the division, the error could be avoided. This has been implemented with PR #100 together with further division-by-zero preventions at other locations in the code. The issue is fixed in beem master and will be rolled out with beem-0.20.7.
Hi @stmdev, thanks for making this contribution.
Thanks also, for proposing a fix and making a pull request to fix the issue.
Thanks again for this contribution. I look forward to your future reports
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator].
Thank you for your review, @fego!
So far this week you've reviewed 3 contributions. Keep up the good work!
Hi @stmdev!
Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server
Hey, @stmdev!
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!