[issue3079] sys.exit() called from optparse - bad, bad, bad

Skip Montanaro report at bugs.python.org
Fri Jun 13 18:46:57 CEST 2008


Skip Montanaro <skip at pobox.com> added the comment:

Georg> I agree with Antoine that the standard behavior is what you want in most
    Georg> simple command-line scripts.

    Georg> It's easy enough to replace the parser's exit function to just print the
    Georg> message, or raise an exception.

Check the code.  Most of the time error is called without an exception
having been raised.  In one case it actually is called and swallows an
exception that the code did raise.  It would be preferable in my mind to
always raise an exception.  If you want, the default can be to catch them
and ignore them as error() does now, but as it stands you can't raise
anything more specific than OptParseError, and that's just a punt even
though specific problems were detected by the code.

Skip

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


More information about the Python-bugs-list mailing list