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

2009-10-15 Thread Phillip M. Feldman
Phillip M. Feldman added the comment: The current behavior of optparse is contrary to how most of Python works. optparse should throw a named exception that can be trapped and identified by the calling program. Doing a SystemExit is unacceptable. I can't believe that this is such a hard thing

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

2009-10-15 Thread R. David Murray
R. David Murray added the comment: There was recently a long discussion of this on python-dev (in the context of a proposal to add argparse to the stdlib; argparse does the same thing). The conclusion was that the current behavior is the most useful behavior, and that if you don't want to exit

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

2009-10-15 Thread Phillip M. Feldman
Phillip M. Feldman added the comment: Thanks for the response! I can indeed catch SystemExit, but I would like to be able to take one action (terminate the program) if the user supplied an unknown option, and another action (prompt for a new value) if the user supplied a bad value for an opt

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

2008-06-11 Thread Skip Montanaro
New submission from Skip Montanaro <[EMAIL PROTECTED]>: This seems like a bug in optparse.OptionParser: def exit(self, status=0, msg=None): if msg: sys.stderr.write(msg) sys.exit(status) def error(self, msg): """error(msg : string) Print a us

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

2008-06-11 Thread Skip Montanaro
Changes by Skip Montanaro <[EMAIL PROTECTED]>: -- versions: +Python 2.6, Python 3.0 ___ Python tracker <[EMAIL PROTECTED]> ___ ___ Pytho

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

2008-06-12 Thread Gabriel Genellina
Changes by Gabriel Genellina <[EMAIL PROTECTED]>: -- nosy: +gagenellina ___ Python tracker <[EMAIL PROTECTED]> ___ ___ Python-bugs-list

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

2008-06-13 Thread Antoine Pitrou
Antoine Pitrou <[EMAIL PROTECTED]> added the comment: The current behaviour is useful in that most of time, it is convenient to let OptionParser display a standard error message and bail out. However, having an attribute on the OptionParser object (e.g. exit_on_errors) to be able to change this b

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

2008-06-13 Thread Georg Brandl
Georg Brandl <[EMAIL PROTECTED]> added the comment: I agree with Antoine that the standard behavior is what you want in most simple command-line scripts. It's easy enough to replace the parser's exit function to just print the message, or raise an exception. -- nosy: +georg.brandl

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

2008-06-13 Thread Skip Montanaro
Skip Montanaro <[EMAIL PROTECTED]> 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 excep