]> 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, 25 Feb 2019 22:13:03 +0000 (22:13 +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>
[Fixup for sumo context]
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
meta/classes/package.bbclass

index 109cf27254cd5db1f004f8379dc50fa5a8b4ccc8..6141a9582d9f8ba811d56f3c7fac2085b406cfb4 100644 (file)
@@ -359,7 +359,8 @@ def append_source_info(file, sourcefile, d, fatal=True):
     # of rpm's debugedit, which was writing them out that way, and the code elsewhere
     # is still assuming that.
     debuglistoutput = '\0'.join(debugsources) + '\0'
-    open(sourcefile, 'a').write(debuglistoutput)
+    with open(sourcefile, 'a') as sf:
+        sf.write(debuglistoutput)
 
 
 def splitdebuginfo(file, debugfile, debugsrcdir, sourcefile, d):