From 7beb4bca6474ea6d94c532c47931afbfb5b0ab74 Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Wed, 17 Jan 2018 13:39:31 +0100 Subject: [PATCH] telegram client: fix infinite recursion in send_file The iterability check added in 36e21019 does not tell away strings from containers of strings, therefore all possible arguments are considered iterable, and the function recurses into itself with each of the items, which again will be considered iterable... So doing now an explicit type check for str before getting to itemizing. (XXX I wonder if bytes/bytearray objects could be taken as arguments? If yes, they should as well be included in the type check.) --- telethon/telegram_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index 9e192028..9dc5ac5c 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -873,7 +873,7 @@ class TelegramClient(TelegramBareClient): """ # First check if the user passed an iterable, in which case # we may want to send as an album if all are photo files. - if hasattr(file, '__iter__'): + if not isinstance(file, str) and hasattr(file, '__iter__'): # Convert to tuple so we can iterate several times file = tuple(x for x in file) if all(utils.is_image(x) for x in file):