id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,branch,branch_author,launchpad_bug
4858,twisted.python.usage.Options errors when generic code for usage.Options definition has multiple underscores.,t_venkatesh,,"When the generic code for options method has multiple underscores, and a short name is declared, twisted produces a traceback.

'''To reproduce define:'''
{{{
from twisted.python import usage
class TestOptions(usage.Options):
    def opt_verbose_big(self):
        ""Call this multiple times to increment verbosity""
        self['verbosity'] += 1
    opt_v = opt_verbose_big
TestOptions().parseOptions()
# Invoke with -v
}}}

'''Traceback:'''
{{{
Traceback (most recent call last):
  File ""/tmp/twistedOptions.py"", line 29, in <module>
    TestOptions().parseOptions()
  File ""<path>/twisted/python/usage.py"", line 216, in parseOptions
    if isinstance(self._dispatch[optMangled], CoerceParameter):
KeyError: 'verbose_big'
}}}

'''Patch:'''
{{{
--- <path>/lib/python/twisted/python/usage.py        2011-02-09 08:35:08.000000000 -0500
+++ /tmp/usage.py       2011-02-09 08:35:02.000000000 -0500
@@ -393,5 +393,5 @@
             if method not in reverse_dct:
                 reverse_dct[method] = []
-            reverse_dct[method].append(name)
+            reverse_dct[method].append(name.replace('_','-'))

         cmpLength = lambda a, b: cmp(len(a), len(b))
}}}

Python 2.6.2

Twisted 8.2.0
",defect,closed,normal,,core,fixed,,,branches/underscore-options-4858,"t_venkatesh, exarkun",
