Fix seeking on strings from c0828f5 when uploading files

This commit is contained in:
Lonami Exo 2019-04-09 09:29:06 +04:00
parent 68291c7b3d
commit 2fb560624d

View File

@ -39,10 +39,11 @@ def _resize_photo_if_needed(
or (isinstance(file, io.IOBase) and not file.seekable())): or (isinstance(file, io.IOBase) and not file.seekable())):
return file return file
before = file.tell() if isinstance(file, io.IOBase) else 0
if isinstance(file, bytes): if isinstance(file, bytes):
file = io.BytesIO(file) file = io.BytesIO(file)
before = file.tell() if isinstance(file, io.IOBase) else None
try: try:
# Don't use a `with` block for `image`, or `file` would be closed. # Don't use a `with` block for `image`, or `file` would be closed.
# See https://github.com/LonamiWebs/Telethon/issues/1121 for more. # See https://github.com/LonamiWebs/Telethon/issues/1121 for more.