Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
made readme file to be opened using with context
The previous example doesn't explicitly close the opened file object. Although it's almost fine if the interpreter is CPython but it could be broken if PyPy. CPython does reference counting instead of garbage collections, and file.__del__() closes the file itself, so files are automatically closed when local scope ends unless these are "leaked" out of local scope, in CPython. PyPy does garbage collection so invocation time of __del__() methods cannot be determined. It means files can be unclosed even if local scope ends and these are never leaked out. If the `funniest` package in the example are being installed as a dependency of another package by easy_install using PyPy, it may cause "too many open files" error. How to prevent this problem is to explicitly close() files or to open files using with context (if Python 2.5+). Many python packages in PyPI read their readme file to fill long_description in setup.py, but this pattern without explicit closing of file should be discouraged.
- Loading branch information