Skip to contentSkip to conversation

package.bbclass: fix python unclosed file ResourceWarning

PATCH New Chen Qi 1 participant 2 messages Dec 18, 2018

lore
Share & tools
lore

Chen Qi

author
#0 lore raw

cover package.bbclass: fix python unclosed file ResourceWarning

*** BLURB HERE ***
The following changes since commit fe43e599327f26b399c1883205e988236a5e51bd:

gcc: Drop 7.3 since 8.2 is working fine for us (2018-12-15 17:10:52 +0000)

are available in the git repository at:

git://git.pokylinux.org/poky-contrib ChenQi/package_warn
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/package_warn

Chen Qi (1):
package.bbclass: fix python unclosed file ResourceWarning

 meta/classes/package.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/1 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'>

---
 meta/classes/package.bbclass | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
meta/classes/package.bbclass +2 -1
index d1e9138..0fe9576 100644
@@ -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)
 
 
Signature · 1 line
1.9.1