steemit / steem-python

The official Python (3) library for the Steem Blockchain.
https://steem.io
MIT License
154 stars 99 forks source link

account.has_voted throws AttributeError #103

Closed DoctorLai closed 6 years ago

DoctorLai commented 6 years ago

I am a fan of the steem-python library, and I think there is a bug in the has_voted method of the account class.

See this code:

from steem.account import Account
import sys

try:
  account = Account("justyy")
  if account.has_voted("@justyy/cn--2017-11-17"):
    print('voted already by has_voted')
except:
  print("Unexpected error:", sys.exc_info()[0])    

Let's run it using python3 test.py assuming above script is saved to test.py

It will always throws the unexpected error - attribute error which basically makes the method unusable.

image.png

The source code is at 136-138 of the official steem-python github page: https://github.com/steemit/steem-python/blob/master/steem/account.py



Open Source Contribution posted via Utopian.io

crokkon commented 6 years ago

Account.has_voted() expects a Post(), not a string:


from steem.account import Account
from steem.post import Post

try:
  account = Account("justyy")
  if account.has_voted(Post("@justyy/cn--2017-11-17")):
    print('voted already by has_voted')
except:
  print("Unexpected error:", sys.exc_info()[0])