]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
report-error.bbclass: Use with to control file handle lifetime
authorOla x Nilsson <ola.x.nilsson@axis.com>
Mon, 21 Oct 2019 10:30:31 +0000 (12:30 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 23 Oct 2019 15:26:14 +0000 (16:26 +0100)
Signed-off-by: Ola x Nilsson <olani@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/report-error.bbclass

index ea043b23e1baeb6d89cf7727465f3355c5a2cf6e..1a12db12060934c18e613fcff3adf102a037ac1f 100644 (file)
@@ -78,19 +78,15 @@ python errorreport_handler () {
             taskdata['task'] = task
             if log:
                 try:
-                    logFile = codecs.open(log, 'r', 'utf-8')
-                    logdata = logFile.read()
-
+                    with codecs.open(log, encoding='utf-8') as logFile:
+                        logdata = logFile.read()
                     # Replace host-specific paths so the logs are cleaner
                     for d in ("TOPDIR", "TMPDIR"):
                         s = e.data.getVar(d)
                         if s:
                             logdata = logdata.replace(s, d)
-
-                    logFile.close()
                 except:
                     logdata = "Unable to read log file"
-
             else:
                 logdata = "No Log"