[New-bugs-announce] [issue9509] argparse FileType raises ugly exception for missing file

Doug Hellmann report at bugs.python.org
Wed Aug 4 15:08:07 CEST 2010


New submission from Doug Hellmann <doug.hellmann at gmail.com>:

Most of the argparse type converters handle exceptions with a single line error message explaining the problem.  For example, if an argument -i is declared as an int, but the value given ('a') cannot be converted to an int, the message is something like "argument -i: invalid int value: 'a'".  

On the other hand, FileType raises an IOError, which isn't being caught and converted to the simpler error message. Instead, a full traceback is printed.  To be consistent, the IOError should be trapped and a single error message printed.

----------
components: Library (Lib)
files: argparse_filetype_error.py
messages: 112798
nosy: doughellmann
priority: normal
severity: normal
status: open
title: argparse FileType raises ugly exception for missing file
versions: Python 2.7, Python 3.2
Added file: http://bugs.python.org/file18380/argparse_filetype_error.py

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


More information about the New-bugs-announce mailing list