Ticket #4858 defect closed fixed
twisted.python.usage.Options errors when generic code for usage.Options definition has multiple underscores.
| Reported by: | t_venkatesh | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | core | Keywords: | |
| Cc: | Branch: | branches/underscore-options-4858 | |
| Author: | t_venkatesh, exarkun | Launchpad Bug: |
Description
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
Change History
Note: See
TracTickets for help on using
tickets.
