Message116355
This is referring to argparse 1.1 installed under Python 2.6. When I was passing in an nargs flag, I figured that since '+' and '*' are valid options, I should pass in strings. So when I tried passing in the string '1' instead of the integer 1, I got the following error:
>>> import argparse
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('foo', nargs='1')
_StoreAction(option_strings=[], dest='foo', nargs='1', const=None, default=None, type=None, choices=None, help=None, metavar=None)
>>> parser.parse_args()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.6-universal/egg/argparse.py", line 1698, in parse_args
File "build/bdist.macosx-10.6-universal/egg/argparse.py", line 1730, in parse_known_args
File "build/bdist.macosx-10.6-universal/egg/argparse.py", line 1935, in _parse_known_args
File "build/bdist.macosx-10.6-universal/egg/argparse.py", line 1884, in consume_positionals
File "build/bdist.macosx-10.6-universal/egg/argparse.py", line 2028, in _match_arguments_partial
File "build/bdist.macosx-10.6-universal/egg/argparse.py", line 2169, in _get_nargs_pattern
TypeError: can't multiply sequence by non-int of type 'str'
Fortunately, I had just added the nargs and knew to correct that. However, if I were to do something like read that value in from a config file and forget to coerce the value from a string to an int, I could see how this could be a giant pain to track down. |
|
Date |
User |
Action |
Args |
2010-09-13 23:25:13 | Jason.Baker | set | recipients:
+ Jason.Baker |
2010-09-13 23:25:12 | Jason.Baker | set | messageid: <1284420312.86.0.187137843637.issue9849@psf.upfronthosting.co.za> |
2010-09-13 23:25:11 | Jason.Baker | link | issue9849 messages |
2010-09-13 23:25:08 | Jason.Baker | create | |
|