From 0a3151175df20e13aea3b8640d992f8cdede33ec Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sun, 3 Jun 2018 12:29:30 +0200 Subject: [PATCH] Fix infinite recursion on setattr custom.Message --- telethon/tl/custom/message.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/telethon/tl/custom/message.py b/telethon/tl/custom/message.py index 02cd1448..58015e46 100644 --- a/telethon/tl/custom/message.py +++ b/telethon/tl/custom/message.py @@ -19,6 +19,7 @@ class Message: in the original :tl:`Message`. """ def __init__(self, client, original, entities, input_chat): + self.__dict__['_init'] = False self.original_message = original self.stringify = self.original_message.stringify self.to_dict = self.original_message.to_dict @@ -42,6 +43,7 @@ class Message: elif fwd.channel_id: self._fwd_from_entity = entities.get(get_peer_id( types.PeerChannel(fwd.channel_id))) + self._init = True def __new__(cls, client, original, entities, input_chat): if isinstance(original, types.Message): @@ -55,7 +57,10 @@ class Message: return getattr(self.original_message, item) def __setattr__(self, name, value): - return setattr(self.original_message, name, value) + if not self._init or name in self.__dict__: + self.__dict__[name] = value + else: + setattr(self.original_message, name, value) def __str__(self): return str(self.original_message)