Queer European MD passionate about IT
Parcourir la source

Close buffered_file only if it exists

Davte il y a 5 ans
Parent
commit
f5c661925c
1 fichiers modifiés avec 2 ajouts et 1 suppressions
  1. 2 1
      davtelepot/bot.py

+ 2 - 1
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: