Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

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

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Jun 11, 2008, 3:50 PM

Post #1 of 3 (172 views)
Permalink
[issue3084] sys.exit() called from optparse - bad, bad, bad

New submission from Skip Montanaro <skip [at] pobox>:

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 usage message incorporating 'msg' to stderr and exit.
If you override this in a subclass, it should not return -- it
should either exit or raise an exception.
"""
self.print_usage(sys.stderr)
self.exit(2, "%s: error: %s\n" % (self.get_prog_name(), msg))

By default I think it should raise an exception when it encounters an error,
not exit. Programmers shouldn't be forced to subclass code in the standard
library to get recommended practice.

If you feel this behavior can't be changed in 2.6 it should at least be
corrected in 3.0.

Skip

----------
messages: 68030
nosy: skip.montanaro
severity: normal
status: open
title: sys.exit() called from optparse - bad, bad, bad

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue3084>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jun 11, 2008, 4:46 PM

Post #2 of 3 (156 views)
Permalink
[issue3084] sys.exit() called from optparse - bad, bad, bad [In reply to]

Skip Montanaro <skip [at] pobox> added the comment:

I originally sent this by email but never saw it pop up. I eventually
submitted via the web.

----------
superseder: -> sys.exit() called from optparse - bad, bad, bad

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue3084>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jun 11, 2008, 4:47 PM

Post #3 of 3 (154 views)
Permalink
[issue3084] sys.exit() called from optparse - bad, bad, bad [In reply to]

Changes by Skip Montanaro <skip [at] pobox>:


----------
status: open -> closed

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue3084>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.