From 2fb560624d0de34655b6ffa879f4a5020a2bf8f2 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 9 Apr 2019 09:29:06 +0400 Subject: [PATCH] Fix seeking on strings from c0828f5 when uploading files --- telethon/client/uploads.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/telethon/client/uploads.py b/telethon/client/uploads.py index a5eed2a4..aed9b136 100644 --- a/telethon/client/uploads.py +++ b/telethon/client/uploads.py @@ -39,10 +39,11 @@ def _resize_photo_if_needed( or (isinstance(file, io.IOBase) and not file.seekable())): return file - before = file.tell() if isinstance(file, io.IOBase) else 0 if isinstance(file, bytes): file = io.BytesIO(file) + before = file.tell() if isinstance(file, io.IOBase) else None + try: # Don't use a `with` block for `image`, or `file` would be closed. # See https://github.com/LonamiWebs/Telethon/issues/1121 for more.