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