]> code.ossystems Code Review - openembedded-core.git/commitdiff
oe.types.path: Use with to control file handle lifetime
authorOla x Nilsson <ola.x.nilsson@axis.com>
Mon, 21 Oct 2019 10:30:27 +0000 (12:30 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 23 Oct 2019 15:26:14 +0000 (16:26 +0100)
Signed-off-by: Ola x Nilsson <olani@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oe/types.py

index 77ee7ee5412176b3f1d418f3da0d92eb25e2d5e8..bbbabafbf6512849f0423dda284939574052363f 100644 (file)
@@ -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
-