From: Ola x Nilsson Date: Mon, 21 Oct 2019 10:30:27 +0000 (+0200) Subject: oe.types.path: Use with to control file handle lifetime X-Git-Tag: uninative-2.8~1289 X-Git-Url: https://code.ossystems.io/gitweb?a=commitdiff_plain;h=b6e7fee68d018e5f148a7a02cf110bc210022a72;p=openembedded-core.git oe.types.path: Use with to control file handle lifetime Signed-off-by: Ola x Nilsson Signed-off-by: Richard Purdie --- 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 -