From: Chen Qi Date: Tue, 18 Dec 2018 06:53:43 +0000 (+0800) Subject: package.bbclass: fix python unclosed file ResourceWarning X-Git-Tag: 2018-10.4-thud~306 X-Git-Url: https://code.ossystems.io/gitweb?a=commitdiff_plain;h=284252d1b6d1672a5b6c042fa591f00d89613a22;p=openembedded-core.git package.bbclass: fix python unclosed file ResourceWarning 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 Signed-off-by: Ross Burton Signed-off-by: Richard Purdie Signed-off-by: Armin Kuster --- diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index d1e9138c66..0fe9576b4d 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass @@ -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)