From: Ola x Nilsson Date: Mon, 21 Oct 2019 10:30:28 +0000 (+0200) Subject: lib/oe/packagedata: Use with to control file handle lifetime X-Git-Tag: lucaceresoli/bug-15201-perf-libtraceevent-missing~12958 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28b3635b7f40b627a9d6294a78589c78f0c682c8;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git lib/oe/packagedata: Use with to control file handle lifetime Signed-off-by: Ola x Nilsson Signed-off-by: Richard Purdie --- diff --git a/meta/lib/oe/packagedata.py b/meta/lib/oe/packagedata.py index cbde380b034..a82085a7920 100644 --- a/meta/lib/oe/packagedata.py +++ b/meta/lib/oe/packagedata.py @@ -17,9 +17,8 @@ def read_pkgdatafile(fn): if os.access(fn, os.R_OK): import re - f = open(fn, 'r') - lines = f.readlines() - f.close() + with open(fn, 'r') as f: + lines = f.readlines() r = re.compile("([^:]+):\s*(.*)") for l in lines: m = r.match(l)