[issue9849] Argparse needs better error handling for nargs
Mark Lawrence
report at bugs.python.org
Mon Apr 15 02:07:44 CEST 2013
Mark Lawrence added the comment:
The behaviour has changed from that given in msg116355. Using Python 3.3.1 on Windows.
>>> import argparse
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('foo', nargs='1')
Traceback (most recent call last):
File "c:\python33\lib\argparse.py", line 1322, in add_argument
self._get_formatter()._format_args(action, None)
File "c:\python33\lib\argparse.py", line 585, in _format_args
formats = ['%s' for _ in range(action.nargs)]
TypeError: 'str' object cannot be interpreted as an integer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\python33\lib\argparse.py", line 1324, in add_argument
raise ValueError("length of metavar tuple does not match nargs")
ValueError: length of metavar tuple does not match nargs
The docs http://docs.python.org/3/library/argparse.html#nargs are clear that nargs is an integer or various types of string so I think this could be closed as already fixed.
----------
nosy: +BreamoreBoy
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9849>
_______________________________________
More information about the Python-bugs-list
mailing list