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: uninative-2.8~1288 X-Git-Url: https://code.ossystems.io/gitweb?a=commitdiff_plain;h=28b3635b7f40b627a9d6294a78589c78f0c682c8;p=openembedded-core.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 cbde380b03..a82085a792 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)