New submission from Chris Withers:
The attached script demonstrates the bug.
option.dest should be set, even if not explicitly supplied in the call
to parser.add_option, by the time the callback is called.
Unless dest='something' is specified in the call to add_option, you will
get the following error when running "python test.py --myopt":
File "test.py", line 4, in mycallback
setattr(parser.values,option.dest,value)
TypeError: attribute name must be string
...as options.dest is still None.
I would expect options.dest to be computed as per the algorithm in
optparse.Option._check_dest.
----------
components: Library (Lib)
files: test.py
messages: 56252
nosy: cjw296
severity: normal
status: open
title: option.dest not set when callback called with optparse
versions: Python 2.3, Python 2.4, Python 2.5
__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1243>
__________________________________
from optparse import OptionParser
def mycallback(option,opt_str,value,parser):
setattr(parser.values,option.dest,value)
parser = OptionParser('bug demo')
parser.add_option('--myopt',action='callback',callback=mycallback)
options,args = parser.parse_args()
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com