From e0e0abdc3fb5ce52252f1507ff72a68e81e72cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Tue, 9 Apr 2024 15:28:15 +0200 Subject: [PATCH] feat: ensure unpack_7zarchive closes the archive --- py7zr/py7zr.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/py7zr/py7zr.py b/py7zr/py7zr.py index 6503b9ad..400588b7 100644 --- a/py7zr/py7zr.py +++ b/py7zr/py7zr.py @@ -1202,9 +1202,8 @@ def unpack_7zarchive(archive, path, extra=None): """ Function for registering with shutil.register_unpack_format(). """ - arc = SevenZipFile(archive) - arc.extractall(path) - arc.close() + with SevenZipFile(archive) as arc: + arc.extractall(path) def pack_7zarchive(base_name, base_dir, owner=None, group=None, dry_run=None, logger=None):