[oe-commits] [openembedded-core] 08/28: oe.types.path: Use with to control file handle lifetime

git at git.openembedded.org git at git.openembedded.org
Tue Oct 22 12:58:47 UTC 2019


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 8837716a0e62cbf27c7e8913d68552691e749b80
Author: Ola x Nilsson <ola.x.nilsson at axis.com>
AuthorDate: Mon Oct 21 12:30:27 2019 +0200

    oe.types.path: Use with to control file handle lifetime
    
    Signed-off-by: Ola x Nilsson <olani at axis.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 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 77ee7ee..bbbabaf 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
-

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list