Skip to content

Commit 87c1d09

Browse files
committed
Close opened file in LinguaMakoExtractor
1 parent 640849a commit 87c1d09

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

mako/ext/linguaplugin.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ def __call__(self, filename, options, fileobj=None):
2727
self.python_extractor = get_extractor("x.py")
2828
if fileobj is None:
2929
fileobj = open(filename, "rb")
30-
return self.process_file(fileobj)
30+
must_close = True
31+
else:
32+
must_close = False
33+
try:
34+
for message in self.process_file(fileobj):
35+
yield message
36+
finally:
37+
if must_close:
38+
fileobj.close()
3139

3240
def process_python(self, code, code_lineno, translator_strings):
3341
source = code.getvalue().strip()

0 commit comments

Comments
 (0)