From 69f08c2eb5a2a68a072debd3e7f274141b6b98bf Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Wed, 1 Jul 2026 03:06:16 -0700 Subject: [PATCH] fix(telegram): guard _post_connect_task access for object.__new__ test pattern disconnect() reads self._post_connect_task, but several tests build a bare TelegramAdapter via object.__new__() without calling __init__ (which sets the attr). Use getattr(..., None) so disconnect() works on those instances too (pitfall #17). --- plugins/platforms/telegram/adapter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/platforms/telegram/adapter.py b/plugins/platforms/telegram/adapter.py index b8748eb0b..1b69a1a39 100644 --- a/plugins/platforms/telegram/adapter.py +++ b/plugins/platforms/telegram/adapter.py @@ -3056,8 +3056,9 @@ class TelegramAdapter(BasePlatformAdapter): # Cancel deferred post-connect housekeeping (command-menu / DM-topic / # status-indicator Bot API calls) so it cannot fire into a half-torn-down - # bot client (#46298). - post_connect_task = self._post_connect_task + # bot client (#46298). getattr guards the object.__new__ test pattern + # where __init__ (which sets this attr) is never called. + post_connect_task = getattr(self, "_post_connect_task", None) if post_connect_task and not post_connect_task.done(): post_connect_task.cancel() await asyncio.gather(post_connect_task, return_exceptions=True)