[oe-commits] [meta-openembedded] 17/33: gitkpkgv: Ensure files are closed

git at git.openembedded.org git at git.openembedded.org
Thu Jun 9 06:54:06 UTC 2016


martin_jansa pushed a commit to branch master
in repository meta-openembedded.

commit 55cb2ec6db42e43c601f77bf4f03fb3a43725b24
Author: Richard Purdie <richard.purdie at linuxfoundation.org>
AuthorDate: Thu Jun 2 10:34:04 2016 +0100

    gitkpkgv: Ensure files are closed
    
    This avoids warnings with python 3.
    
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
    Signed-off-by: Martin Jansa <Martin.Jansa at gmail.com>
---
 meta-oe/classes/gitpkgv.bbclass | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/meta-oe/classes/gitpkgv.bbclass b/meta-oe/classes/gitpkgv.bbclass
index 1cba00c..4866fac 100644
--- a/meta-oe/classes/gitpkgv.bbclass
+++ b/meta-oe/classes/gitpkgv.bbclass
@@ -87,11 +87,13 @@ def get_git_pkgv(d, use_tags):
 
                     if commits != "":
                         oe.path.remove(rev_file, recurse=False)
-                        open(rev_file, "w").write("%d\n" % int(commits))
+                        with open(rev_file, "w") as f:
+                            f.write("%d\n" % int(commits))
                     else:
                         commits = "0"
                 else:
-                    commits = open(rev_file, "r").readline(128).strip()
+                    with open(rev_file, "r") as f:
+                        commits = f.readline(128).strip()
 
                 if use_tags:
                     try:

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


More information about the Openembedded-commits mailing list