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

erro no python 3.7 #18

Open
romeucampos opened this issue Mar 17, 2019 · 3 comments
Open

erro no python 3.7 #18

romeucampos opened this issue Mar 17, 2019 · 3 comments

Comments

@romeucampos
Copy link

C:\Users\Romeupc\GgUzbKZNcKZZiEWbVtSxtNhC44Zh3tX2pfon37\python.exe "C:/Users/Romeupc/PycharmProjects/untitled1/teste mbtc.py"
Traceback (most recent call last):
File "C:/Users/Romeupc/PycharmProjects/untitled1/teste mbtc.py", line 5, in
print(mbtc.list_orders(coin_pair="BRLBTC"))
File "C:\Users\Romeupc\GgUzbKZNcKZZiEUzCE1pZpitdNYTNRLAZacF4eKrUf35f66-packages\mercadobitcoin\trade_api.py", line 74, in list_orders
return self.__check_response(self.__post_tapi("list_orders", kwargs ))
File "C:\Users\Romeupc\GgUzbKZNcKZZiEUzCE1pZpitdNYTNRLAZacF4eKrUf35f66-packages\mercadobitcoin\trade_api.py", line 133, in __post_tapi
"TAPI-MAC": self.__signature(payload)
File "C:\Users\Romeupc\GgUzbKZNcKZZiEUzCE1pZpitdNYTNRLAZacF4eKrUf35f66-packages\mercadobitcoin\trade_api.py", line 141, in __signature
signature = hmac.new(self.secret, digestmod=hashlib.sha512)
File "C:\Users\Romeupc\GgUzbKZNcKZZiEUzCE1pZpitdNYTNRLAZacF4eKrUf35f66.py", line 153, in new
return HMAC(key, msg, digestmod)
File "C:\Users\Romeupc\GgUzbKZNcKZZiEUzCE1pZpitdNYTNRLAZacF4eKrUf35f66.py", line 49, in init
raise TypeError("key: expected bytes or bytearray, but got %r" % type(key).name)
TypeError: key: expected bytes or bytearray, but got 'str'

Process finished with exit code 1

@FernandoGaspar
Copy link

Can you solved?

@guilhermesilvame
Copy link

guilhermesilvame commented Aug 11, 2019

A possible solution is:

Instead of doing:

mbtc = TradeApi(<API_ID>, <API_SECRET>)

Do this:

mbtc = TradeApi(<API_ID>, bytes(<API_SECRET>, 'latin1'))

Contact the author to fix the source code to work in Python 3.x.

@lbltavares
Copy link

You can also modify the file trade_api.py, line 141:
signature = hmac.new(self.secret, digestmod=hashlib.sha512)
to:
signature = hmac.new(self.secret.encode(), digestmod=hashlib.sha512)

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

No branches or pull requests

4 participants