From c3071ac8f834c13bc014ea7cb77a9d2b9c6eb3ed Mon Sep 17 00:00:00 2001 From: Oleg A Date: Sun, 5 Jan 2025 13:30:13 +0300 Subject: [PATCH] fix: prevent endless loop with buttons --- aiogram/utils/keyboard.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/aiogram/utils/keyboard.py b/aiogram/utils/keyboard.py index 23659b8f..fe806f7a 100644 --- a/aiogram/utils/keyboard.py +++ b/aiogram/utils/keyboard.py @@ -179,9 +179,12 @@ class KeyboardBuilder(Generic[ButtonType], ABC): last_row.extend(head) # Separate buttons to exclusive rows with max possible row width - while buttons: - row, buttons = buttons[: self.max_width], buttons[self.max_width :] - markup.append(list(row)) + if self.max_width > 0: + while buttons: + row, buttons = buttons[: self.max_width], buttons[self.max_width :] + markup.append(list(row)) + else: + markup.append(list(buttons)) self._markup = markup return self