[issue13824] argparse.FileType opens a file and never closes it
Steven Bethard
report at bugs.python.org
Sat Jul 21 23:01:09 CEST 2012
Steven Bethard <steven.bethard at gmail.com> added the comment:
So I generally agree that FileType is not what you want for anything but quick scripts that can afford to either leave a file open or to close stdin and/or stdout. However, quick scripts are an important use case for argparse, so I don't think we should get rid of FileType.
What should definitely happen:
* Someone should add some documentation explaining the risks of using FileType (e.g. forgetting to close the file, or closing stdin/stdout when you didn't mean to).
What could potentially happen if someone really wanted it:
* Someone could create a "safe" replacement, e.g. a FileOpenerType that returns an object with open() and close() methods that do the right things (or whatever API makes sense).
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13824>
_______________________________________
More information about the Python-bugs-list
mailing list