Windows 7 Pro 32 bit, Py 2.6.2, wxPy 2.8.10.1-ansi
I was toying, in fact learning, the Python optparse module.
When I introduced the following in my interactive Python shell, psi,
it causes a Python crash. There is a course a mistake in the code:
incomplete fake_args lists, missing filename parameter.
from optparse import OptionParser
parser = OptionParser()
parser.add_option('-f', '--file', dest='filename')
-f/--file
fake_args = ['-f']
(options, args) = parser.parse_args(fake_args)
[Python crashes and the app window (main wx.Frame) closes]
I repeated the experiment with PyShell, same behaviour.
from optparse import OptionParser
parser = OptionParser()
parser.add_option('-f', '--file', dest='filename')
<Option at 0x30310a8: -f/--file>
fake_args = ['-f']
(options, args) = parser.parse_args(fake_args)
[Python crashes and main frame closes]
With IDLE, the error is intercepted.
from optparse import OptionParser
parser = OptionParser()
parser.add_option('-f', '--file', dest='filename')
<Option at 0x2714620: -f/--file>
fake_args = ['-f']
(options, args) = parser.parse_args(fake_args)
Usage: [options]
: error: -f option requires an argument
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
(options, args) = parser.parse_args(fake_args)
File "C:\Python26\lib\optparse.py", line 1394, in parse_args
stop = self._process_args(largs, rargs, values)
File "C:\Python26\lib\optparse.py", line 1438, in _process_args
self._process_short_opts(rargs, values)
File "C:\Python26\lib\optparse.py", line 1532, in
_process_short_opts
self.error(_("%s option requires an argument") % opt)
File "C:\Python26\lib\optparse.py", line 1578, in error
self.exit(2, "%s: error: %s\n" % (self.get_prog_name(), msg))
File "C:\Python26\lib\optparse.py", line 1568, in exit
sys.exit(status)
SystemExit: 2
No idea, from where this may come.
Jean-Michel Fauth, Switzerland