From c706154509577bb58c3034e750f54ed8acf73ad2 Mon Sep 17 00:00:00 2001 From: Allerter <45076212+Allerter@users.noreply.github.com> Date: Wed, 2 Sep 2020 19:11:10 +0430 Subject: [PATCH] added closing the file opened by the parser if file's on the disk --- telethon/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/telethon/utils.py b/telethon/utils.py index fd26dc52..1c125019 100644 --- a/telethon/utils.py +++ b/telethon/utils.py @@ -607,6 +607,8 @@ def _get_metadata(file): try: file = io.BytesIO(file) if isinstance(file, bytes) else file parser = hachoir.parser.createParser(file) + if isinstance(file, str): + parser.close() return hachoir.metadata.extractMetadata(parser) except Exception as e: _log.warning('Failed to analyze %s: %s %s', file, e.__class__, e)