[issue9509] argparse FileType raises ugly exception for missing file

SilentGhost report at bugs.python.org
Thu Nov 25 01:35:03 CET 2010


SilentGhost <michael.mischurow+bpo at gmail.com> added the comment:

Attached patch with the try-except clause as suggested by Steven, Doug's example now produces the following output:

$ ./python argparse_filetype_error.py
usage: argparse_filetype_error.py [-h] [-i I]
argparse_filetype_error.py: error: no such file or directory 'file-does-not-exist.txt'

I have digressed and fixed an issue with _bufsize 0. I thought it would be just natural to default to -1 which is default buffering size for a simple open call anyway. It also makes for a cleaner try-except clause. All tests pass, including akira's.

----------
nosy: +SilentGhost
Added file: http://bugs.python.org/file19805/argparse.py.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9509>
_______________________________________


More information about the Python-bugs-list mailing list