From c4f2a115f72795e4c10870107485ca1266565bd0 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Mon, 21 Oct 2019 12:30:27 +0200 Subject: oe.types.path: Use with to control file handle lifetime (From OE-Core rev: b6e7fee68d018e5f148a7a02cf110bc210022a72) Signed-off-by: Ola x Nilsson Signed-off-by: Richard Purdie --- meta/lib/oe/types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meta/lib/oe/types.py b/meta/lib/oe/types.py index 77ee7ee541..bbbabafbf6 100644 --- a/meta/lib/oe/types.py +++ b/meta/lib/oe/types.py @@ -154,7 +154,8 @@ def path(value, relativeto='', normalize='true', mustexist='false'): if boolean(mustexist): try: - open(value, 'r') + with open(value, 'r'): + pass except IOError as exc: if exc.errno == errno.ENOENT: raise ValueError("{0}: {1}".format(value, os.strerror(errno.ENOENT))) @@ -183,4 +184,3 @@ def qemu_use_kvm(kvm, target_arch): elif build_arch == target_arch: use_kvm = True return use_kvm - -- cgit v1.2.3-54-g00ecf