[OE-core] [PATCH 3/9] lib/oe/packagedata: Use with to control file handle lifetime
Ola x Nilsson
ola.x.nilsson at axis.com
Mon Oct 21 10:30:28 UTC 2019
Signed-off-by: Ola x Nilsson <olani at axis.com>
---
meta/lib/oe/packagedata.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
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)
--
2.11.0
More information about the Openembedded-core
mailing list