From 80c9c5dad3d1602f9bf89ece9f392adca7e3e65d Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Wed, 26 Jun 2019 11:16:02 +0200 Subject: [PATCH] Avoid memory cycle in Forward --- telethon/tl/custom/forward.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/telethon/tl/custom/forward.py b/telethon/tl/custom/forward.py index ecccba98..7943effa 100644 --- a/telethon/tl/custom/forward.py +++ b/telethon/tl/custom/forward.py @@ -24,7 +24,10 @@ class Forward(ChatGetter, SenderGetter): in the original :tl:`MessageFwdHeader`. """ def __init__(self, client, original, entities): - self.__dict__ = original.__dict__ + # Copy all the fields, not reference! It would cause memory cycles: + # self.original_fwd.original_fwd.original_fwd.original_fwd + # ...would be valid if we referenced. + self.__dict__ = dict(original.__dict__) self._client = client self.original_fwd = original