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

Calling the deprecated sha3 method as an instance (bound) method causes an error. #1349

Closed
nbt-rezaem opened this issue May 8, 2019 · 0 comments

Comments

@nbt-rezaem
Copy link
Contributor

  • Version: 5.0.0b1
  • Python: 3.7
  • OS: win
  • pip freeze output
attrdict==2.0.1
certifi==2019.3.9
chardet==3.0.4
cytoolz==0.9.0.1
eth-abi==2.0.0b8
eth-account==0.3.0
eth-hash==0.2.0
eth-keyfile==0.5.1
eth-keys==0.2.2
eth-rlp==0.1.2
eth-typing==2.1.0
eth-utils==1.5.2
ethpm==0.1.4a15
hexbytes==0.1.0
idna==2.8
ipfsapi==0.4.3
jsonschema==2.6.0
lru-dict==1.1.6
parsimonious==0.8.1
protobuf==3.7.1
pycryptodome==3.8.1
pypiwin32==223
pywin32==224
requests==2.21.0
rlp==1.1.0
six==1.12.0
toolz==0.9.0
urllib3==1.24.3
web3==5.0.0b1
websockets==7.0

What was wrong?

Calling the deprecated sha3 method as an instance (bound) method causes an error.

Please include any of the following that are applicable:

>>> import web3
>>> w3 = web3.Web3()
>>> foo='hello()'
>>> w3.keccak(text=foo)
HexBytes('0x19ff1d210e06a53ee50e5bad25fa509a6b00ed395695f7d9b82b68155d9e1065')
>>> web3.Web3.sha3(text=foo)
HexBytes('0x19ff1d210e06a53ee50e5bad25fa509a6b00ed395695f7d9b82b68155d9e1065')
>>> w3.sha3(text=foo)
__main__:1: DeprecationWarning: sha3 is deprecated in favor of keccak
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".\v5\lib\site-packages\web3\_utils\decorators.py", line 57, in wrapper
    return to_wrap(*args, **kwargs)
  File ".\v5\lib\site-packages\eth_utils\functional.py", line 46, in inner
    return callback(fn(*args, **kwargs))
  File ".\v5\lib\site-packages\web3\main.py", line 169, in sha3
    return Web3.keccak(primitive, text, hexstr)
  File ".\v5\lib\site-packages\eth_utils\functional.py", line 46, in inner
    return callback(fn(*args, **kwargs))
  File ".\v5\lib\site-packages\web3\main.py", line 183, in keccak
    {'text': text, 'hexstr': hexstr}
TypeError: You called keccak with first arg <web3.main.Web3 object at 0x0150E5F0> and keywords {'text': 'hello()', 'hexstr': None}. You must call it with one of these approaches: keccak(text='txt'), keccak(hexstr='0x747874'), keccak(b'\x74\x78\x74'), or keccak(0x747874).

How can it be fixed?

I have a pull request to add @staticmethod to the definition to fix this.
After the pull request:

>>> w3.sha3(text=foo)
__main__:1: DeprecationWarning: sha3 is deprecated in favor of keccak
HexBytes('0x19ff1d210e06a53ee50e5bad25fa509a6b00ed395695f7d9b82b68155d9e1065')
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

2 participants