Skip to content

Commit 0709eae

Browse files
committed
boot-qemu.py: Use context manager for pathlib open() calls
New pylint warns: boot-qemu.py:413:8: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) boot-qemu.py:418:8: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) We do not expect these calls to fail but the refactoring is simple to silence the warning. Signed-off-by: Nathan Chancellor <nathan@kernel.org>
1 parent 66e1883 commit 0709eae

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

boot-qemu.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,14 @@ def get_efi_args(guest_arch):
411411

412412
efi_img_qemu = base_folder.joinpath("images", guest_arch, "efi.img")
413413
shutil.copyfile(efi_img, efi_img_qemu)
414-
efi_img_qemu.open(mode="r+b").truncate(efi_img_size)
414+
with efi_img_qemu.open(mode="r+b") as file:
415+
file.truncate(efi_img_size)
415416

416417
efi_vars_qemu = base_folder.joinpath("images", guest_arch,
417418
"efivars.img")
418419
efi_vars_qemu.unlink(missing_ok=True)
419-
efi_vars_qemu.open(mode="xb").truncate(efi_img_size)
420+
with efi_vars_qemu.open(mode="xb") as file:
421+
file.truncate(efi_img_size)
420422

421423
elif guest_arch == "x86_64":
422424
efi_img_qemu = efi_img # This is just usable, it is marked read only

0 commit comments

Comments
 (0)