-
Notifications
You must be signed in to change notification settings - Fork 6k
Labels
ℹ️ good-first-issueinformation: good-first-issueinformation: good-first-issue
Milestone
Description
Steps to Reproduce
- get an instance of
Message - run
message['from'],message['from_user']andmessage['false_key'] - the first gives
None, the second gives the user, the 3rd givesNone
Expected behaviour
- both
message['from']andmessage['from_user']return the user message['false_key']raisesKeyError. This behavior was apparently lost in Add __slots__ #2345 for some reason
Actual behaviour
message['from']givesNonemessage['from_user']return the usermessage['false_key']returnsNone
Operating System
Any
Version of Python, python-telegram-bot & dependencies
branches master and v14Relevant log output
No response
Additional Context
-
This is easy to fix by adapting
TelegramObject.__getitem__to raiseKeyErrorwhen the attribute is not found and introducing a special case whereobj['from']looks up'from_user'. -
In addition,
Messageoverrides__getitem__, but this is actually not necessary. This should be removed. -
A PR for this should be based on v14. see Hacktoberfest 2021 #2681
Metadata
Metadata
Assignees
Labels
ℹ️ good-first-issueinformation: good-first-issueinformation: good-first-issue