[OE-core] [PATCH 1/1] package.bbclass: fix python unclosed file ResourceWarning

Chen Qi Qi.Chen at windriver.com
Tue Dec 18 06:53:43 UTC 2018


Fix the following warning.

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

Signed-off-by: Chen Qi <Qi.Chen at windriver.com>
---
 meta/classes/package.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index d1e9138..0fe9576 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)
 
 
-- 
1.9.1



More information about the Openembedded-core mailing list