[r21829]ImportProGen: Prevent leaking file handle

svn: r21832
This commit is contained in:
John Ralls 2013-03-31 22:51:26 +00:00
parent 9d8d1576b4
commit d3d80b443e

View File

@ -462,7 +462,9 @@ class PG30_Def:
# This can throw a IOError # This can throw a IOError
import io 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] lines = [l.strip() for l in lines]
content = '\n'.join(lines).encode('utf-8') content = '\n'.join(lines).encode('utf-8')
parts = re.split(r'\n(?=\[)', content) parts = re.split(r'\n(?=\[)', content)