dabeaz/ply — pull request #9 by furrykef (2011-12-25 12:30:39+00:00)
Title: Files now close when exception raised

CPython automatically closes files when they go out of scope, but many other Python implementations, such as PyPy, do not. My 65816 assembler runs 10x as fast with PyPy than without, which I think is nothing to sneeze at, so I think it's seriously worth considering taking such implementations into consideration. I have therefore added try-finally blocks to all places where files are opened so that the files are closed even if an exception is raised.

This also involved some modification to the PlyLogger class so that it can optinally close its file when done.