telethon.tl.types.Message is unhashable after upgraded to 0.17+
See original GitHub issueAfter upgrade from 0.16.2.x to 0.17+, our App broken due to telethon.tl.types.Message
become unhashable.
Following is a simple test case to reproduce this issue:
from telethon.tl.types import Message
print('Message.__hash__:', Message.__hash__)
msg = Message(1, None, None, 'Testing 1')
testSet = set([msg])
testSet |= set([msg])
print('testSet: ', testSet)
Output from 0.16.2.3:
telethon-0.16.2.3>pip3 install telethon==0.16.2.3
telethon-0.16.2.3>test_case.py
Message.__hash__: <slot wrapper '__hash__' of 'object' objects>
testSet: {<telethon.tl.types.Message object at 0x017B0BF0>}
Output from 0.17.4.5:
telethon-0.16.2.3>pip3 install telethon==0.17.4.5
telethon-0.17.4.5>test_case.py
Message.__hash__: None
Traceback (most recent call last):
File "...\test_case.py", line 5, in <module>
testSet = set([msg])
TypeError: unhashable type: 'Message'
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
How to Handle Unhashable Type List Exceptions in Python
The Python TypeError: Unhashable Type: 'list' happens when a mutable list, instead of an immutable tuple, is used as a hash argument.
Read more >How to use the telethon.tl.types.Message function in ... - Snyk
Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately. message = types. Message( id=777,...
Read more >ChangeLog - ftp
4 with following changes: * Make the binaries built in the unprivileged apptainer package relocatable. When moving the binaries to a new location,...
Read more >TypeError : Unhashable type - python - Stack Overflow
A list is unhashable because its contents can change over its lifetime. You can update an item contained in the list at any...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I was unaware TLObjects ever were hashable. You can
obj.to_dict()
instead and pick what you need. Or make adict
by{msg.id: msg}
.Your solution then is
{id(obj): obj}
and.update()
it, or settingTLObject.__hash__ = lambda self: id(self)
.