From f5c661925cf1da863c6a6fcfcb36a1435b32ca8e Mon Sep 17 00:00:00 2001 From: Davte Date: Sun, 21 Jul 2019 17:45:39 +0200 Subject: [PATCH] Close buffered_file only if it exists --- davtelepot/bot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/davtelepot/bot.py b/davtelepot/bot.py index 6bcdda1..03a4225 100644 --- a/davtelepot/bot.py +++ b/davtelepot/bot.py @@ -1274,7 +1274,8 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject): document = buffered_file except FileNotFoundError: document = None - buffered_file.close() + if buffered_file: + buffered_file.close() else: use_stored_file_id = False if document is None: