From d3d80b443e4d6950deb758c5ca426386719149b3 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sun, 31 Mar 2013 22:51:26 +0000 Subject: [PATCH] [r21829]ImportProGen: Prevent leaking file handle svn: r21832 --- 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)