From 10585e02d34a85376404f71a9ae706e401ac5ae2 Mon Sep 17 00:00:00 2001 From: dennisvang <29799340+dennisvang@users.noreply.github.com> Date: Mon, 12 Feb 2024 10:17:22 +0100 Subject: [PATCH] undo parenthesized context, for python 3.8 support --- src/tufup/common.py | 14 ++++++-------- tests/test_common.py | 8 +++----- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/tufup/common.py b/src/tufup/common.py index 6ecb19a..5ca2b61 100644 --- a/src/tufup/common.py +++ b/src/tufup/common.py @@ -203,14 +203,12 @@ def diff_and_hash( Returns a dict with size and hash of the *uncompressed* destination archive. """ - with ( - gzip.open(src_path, mode='rb') as src_file, - gzip.open(dst_path, mode='rb') as dst_file, - ): - dst_tar_content = dst_file.read() - patch_path.write_bytes( - bsdiff4.diff(src_bytes=src_file.read(), dst_bytes=dst_tar_content) - ) + with gzip.open(src_path, mode='rb') as src_file: + with gzip.open(dst_path, mode='rb') as dst_file: + dst_tar_content = dst_file.read() + patch_path.write_bytes( + bsdiff4.diff(src_bytes=src_file.read(), dst_bytes=dst_tar_content) + ) return cls._get_tar_size_and_hash(tar_content=dst_tar_content) @classmethod diff --git a/tests/test_common.py b/tests/test_common.py index 4c65d83..e4d99fb 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -232,8 +232,6 @@ def test_patch_and_verify(self): self.assertTrue(dst_path.exists()) # note that gzip compressed files are not reproducible by default (even when # using identical uncompressed data), so we must compare the uncompressed data - with ( - gzip.open(self.targz_paths[dst], mode='rb') as original_tar, - gzip.open(dst_path, mode='rb') as reconstructed_tar, - ): - self.assertEqual(original_tar.read(), reconstructed_tar.read()) + with gzip.open(self.targz_paths[dst], mode='rb') as original_tar: + with gzip.open(dst_path, mode='rb') as reconstructed_tar: + self.assertEqual(original_tar.read(), reconstructed_tar.read())