summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOla x Nilsson <ola.x.nilsson@axis.com>2019-10-21 12:30:31 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-10-23 16:26:14 +0100
commitab108dfc690fb95b66f1c6243ff165f0849fa2b1 (patch)
treed83d953a57d7b6ab24a89517960f645efb5ed1ba
parente3e86d6683e305865c9fd171c6081aec037d9870 (diff)
downloadopenembedded-core-contrib-ab108dfc690fb95b66f1c6243ff165f0849fa2b1.tar.gz
report-error.bbclass: Use with to control file handle lifetime
Signed-off-by: Ola x Nilsson <olani@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/report-error.bbclass8
1 files changed, 2 insertions, 6 deletions
diff --git a/meta/classes/report-error.bbclass b/meta/classes/report-error.bbclass
index ea043b23e1..1a12db1206 100644
--- a/meta/classes/report-error.bbclass
+++ b/meta/classes/report-error.bbclass
@@ -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"