You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pip freeze output omitted since not a package specific issue
What was wrong?
Note: Not exactly an issue but something I had to circumvent myself when using the library and thinking it may be helpful if web3.py handled it instead directly.
I was trying to use functions requiring __hash__ on event logs and the code failed saying lists are not hashable here. This happens if the event logs contain list objects nested inside them (which some smart contracts seem to return), as lists by default are mutable and thus not hashable in Python.
How can it be fixed?
Would it make sense to (possibly recursively) cast any present lists to tuples inside the hash function to avoid crashes? Would some detection mechanism inside these pseudo-immutable classes be helpful to make sure they are indeed hashable (e.g., raising an error if a list is added)?
Any thoughts?
The text was updated successfully, but these errors were encountered:
Was thinking of adding an additional class simulating immutable lists similar to the already present AttributeDict logic, but I believe that would bring unneeded complexity and little practical benefit. I think the simplest approach would be to leave the lists as is, but only convert them recursively to tuples inside the hash checks, with preserved sorting, so that those will not crash anymore.
If you have any thoughts feel free to let me know, otherwise I would proceed with implementation.
Give me some time (~2 weeks), I will put in a small PR.
What was wrong?
Note: Not exactly an issue but something I had to circumvent myself when using the library and thinking it may be helpful if
web3.py
handled it instead directly.I was trying to use functions requiring
__hash__
on event logs and the code failed saying lists are not hashable here. This happens if the event logs containlist
objects nested inside them (which some smart contracts seem to return), as lists by default are mutable and thus not hashable in Python.How can it be fixed?
Would it make sense to (possibly recursively) cast any present lists to tuples inside the hash function to avoid crashes? Would some detection mechanism inside these pseudo-immutable classes be helpful to make sure they are indeed hashable (e.g., raising an error if a list is added)?
Any thoughts?
The text was updated successfully, but these errors were encountered: