diff --git a/telethon/client/downloads.py b/telethon/client/downloads.py index 5f14ceab..67388e44 100644 --- a/telethon/client/downloads.py +++ b/telethon/client/downloads.py @@ -439,7 +439,10 @@ class DownloadMethods: if inspect.isawaitable(r): await r - f.flush() + # Not all IO objects have flush (see #1227) + if callable(getattr(f, 'flush', None)): + f.flush() + if in_memory: return f.getvalue() finally: