Queer European MD passionate about IT
瀏覽代碼

Close buffered_file only if it exists

Davte 5 年之前
父節點
當前提交
f5c661925c
共有 1 個文件被更改,包括 2 次插入1 次删除
  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: