]> code.ossystems Code Review - openembedded-core.git/commitdiff
package.bbclass: fix python unclosed file ResourceWarning
authorChen Qi <Qi.Chen@windriver.com>
Tue, 18 Dec 2018 06:53:43 +0000 (14:53 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 28 Jan 2019 16:56:28 +0000 (16:56 +0000)
Fix the following warning.

  ResourceWarning: unclosed file <_io.TextIOWrapper name='/.../systemd/1_239-r0/debugsources.list' mode='a' encoding='UTF-8'>

(From OE-Core rev: 91810a57f0edd8b37c5f3f989a5aca69d9a40b37)

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
meta/classes/package.bbclass

index d1e9138c6686bcdba91aca5dbc7195089f96a5f3..0fe9576b4db43f2210996dfe3d4a1093ee3186cc 100644 (file)
@@ -368,7 +368,8 @@ def append_source_info(file, sourcefile, d, fatal=True):
     # is still assuming that.
     debuglistoutput = '\0'.join(debugsources) + '\0'
     lf = bb.utils.lockfile(sourcefile + ".lock")
-    open(sourcefile, 'a').write(debuglistoutput)
+    with open(sourcefile, 'a') as sf:
+        sf.write(debuglistoutput)
     bb.utils.unlockfile(lf)