pytries / hat-trie

HAT-Trie for Python
MIT License
86 stars 21 forks source link

Ensure file handles are closed in setup.py #16

Closed svisser closed 10 years ago

svisser commented 10 years ago

This change ensures the file handles are closed properly in setup.py.

kmike commented 10 years ago

Thanks! Is it a cleanup, or you have a practical issue with open(..).read()? File handles are closed when setup.py exits; usually this happens soon.

svisser commented 10 years ago

@kmike actually, if execution is stopped before setup.py finishes (interruption via keyboard, process killed or some other reason) then I'm not sure whether the file handles are properly closed. This change ensures the risk of not closing a file is reduced.

kmike commented 10 years ago

Handles are closed by OS in this case. Python-level close() method may remain uncalled; this could be an issue if we write to files (because it could cause a buffer not to be flushed), but for reading it is not a problem.

kmike commented 10 years ago

I'm fine with merging it if you change the code to use context managers.

svisser commented 10 years ago

Ah, they were introduced in Python 2.5 - somehow I thought they were introduced in Python 2.6.

The above commit changes the code to use context managers.

kmike commented 10 years ago

Thanks!