From 2fe5255b117675f86e134e1f2ae02a24732fd3f7 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sun, 31 Mar 2013 22:46:17 +0000 Subject: [PATCH] ImportProGen: Prevent leaking file handle svn: r21829 --- gramps/plugins/importer/importprogen.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gramps/plugins/importer/importprogen.py b/gramps/plugins/importer/importprogen.py index 095996d3c..6279f8021 100644 --- a/gramps/plugins/importer/importprogen.py +++ b/gramps/plugins/importer/importprogen.py @@ -462,7 +462,9 @@ class PG30_Def: # This can throw a IOError import io - lines = io.open(fname, buffering=1, encoding='cp437', errors='strict').readlines() + lines = None + with f = io.open(fname, buffering=1, encoding='cp437', errors='strict'): + lines = f.readlines() lines = [l.strip() for l in lines] content = '\n'.join(lines).encode('utf-8') parts = re.split(r'\n(?=\[)', content)