Commits

Philip Jenvey committed dda7753

defer temp file creation until after any potential lexer exceptions
fixes #69

  • Participants
  • Parent commits 8876378

Comments (0)

Files changed (2)

 - fixed bug in python generation when variable names are used
   with identifiers like "else", "finally", etc. inside them
   [ticket:68]
+- fixed lexer exceptions not cleaning up temporary files, which
+  could lead to a maximum number of file descriptors used in the
+  process [ticket:69]
   
 0.1.10
 - fixed propagation of 'caller' such that nested %def calls

File lib/mako/template.py

 
 def _compile_module_file(template, text, filename, outputpath):
     identifier = template.module_id
-    (dest, name) = tempfile.mkstemp()
     lexer = Lexer(text, filename, input_encoding=template.input_encoding, preprocessor=template.preprocessor)
     node = lexer.parse()
     source = codegen.compile(node, template.uri, filename, default_filters=template.default_filters, buffer_filters=template.buffer_filters, imports=template.imports, source_encoding=lexer.encoding)
+    (dest, name) = tempfile.mkstemp()
     os.write(dest, source)
     os.close(dest)
     shutil.move(name, outputpath)