[issue9849] Argparse needs better error handling for nargs

2020-11-06 Thread Irit Katriel
Irit Katriel added the comment: This is fixed now: Python 3.10.0a2+ (heads/bpo-42184:f3cb814315, Nov 7 2020, 00:31:51) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import argparse >>> parser = argparse.ArgumentParser() >>>

[issue9849] Argparse needs better error handling for nargs

2019-08-29 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: bethard -> rhettinger nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list

[issue9849] Argparse needs better error handling for nargs

2014-06-08 Thread paul j3
paul j3 added the comment: http://bugs.python.org/issue21666 raises the possibility of testing the 'help' parameter in the same way. By adding (to _check_argument): # check the 'help' string try: self._get_formatter()._expand_help(action) except

[issue9849] Argparse needs better error handling for nargs

2014-02-03 Thread Mark Lawrence
Changes by Mark Lawrence breamore...@yahoo.co.uk: -- nosy: -BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9849 ___ ___

[issue9849] Argparse needs better error handling for nargs

2013-07-08 Thread paul j3
paul j3 added the comment: I included this patch (with minor changes) in a patch that I just posted to http://bugs.python.org/issue16468. That issue deals with the argument choices option, which can be tested along with nargs and metavars. -- ___

[issue9849] Argparse needs better error handling for nargs

2013-04-24 Thread paul j3
paul j3 added the comment: This patch adds a value test for nargs during add_argument. The core of the new test is in ArgumentParser._check_argument. add_argument() now calls ArgumentParser._check_argument(), which calls _format_args(). If it gets a TypeError, it raises a metavar ValueError

[issue9849] Argparse needs better error handling for nargs

2013-04-24 Thread paul j3
paul j3 added the comment: The attached test_nargswarn.py file tests the argparse.py patch. It tries out various nargs values, both for parsers, groups, and mutually exclusive groups. I intend to recast these to work in test_argparse.py -- Added file:

[issue9849] Argparse needs better error handling for nargs

2013-04-24 Thread paul j3
paul j3 added the comment: This is a revision of yesterday's patch. It includes a couple of test cases that check that parser, groups, and exclusive groups all produce the error message. I also changed the metavar tuple case to return an ArgumentError, and changed test_argparse.py

[issue9849] Argparse needs better error handling for nargs

2013-04-23 Thread paul j3
paul j3 added the comment: This nargs test using the formater applies only when the container has a help formatter. That is true for a ArgumentParser, but not for an argument_group. group = parser.add_argument_group('g') group.add_argument('bar', nargs='test') does not raise an error.

[issue9849] Argparse needs better error handling for nargs

2013-04-17 Thread Mark Lawrence
Mark Lawrence added the comment: The first error raised is TypeError: 'str' object cannot be interpreted as an integer, followed by ValueError: length of metavar tuple does not match nargs. Therefore the code has already been changed to reflect the title of this issue. If other code changes

[issue9849] Argparse needs better error handling for nargs

2013-04-16 Thread paul j3
paul j3 added the comment: It does shift the error from parse_args to add_argument, but the message 'ValueError: length of metavar tuple does not match nargs', indicates that it's a side effect of checking on the tuple form of `metavar`. http://bugs.python.org/issue9348 There is still room

[issue9849] Argparse needs better error handling for nargs

2013-04-16 Thread Ned Deily
Changes by Ned Deily n...@acm.org: -- nosy: -ned.deily ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9849 ___ ___ Python-bugs-list mailing list

[issue9849] Argparse needs better error handling for nargs

2013-04-14 Thread Mark Lawrence
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,

[issue9849] Argparse needs better error handling for nargs

2010-11-02 Thread Éric Araujo
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo stage: - needs patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9849 ___ ___

[issue9849] Argparse needs better error handling for nargs

2010-09-13 Thread Jason Baker
New submission from Jason Baker amnorv...@gmail.com: 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

[issue9849] Argparse needs better error handling for nargs

2010-09-13 Thread Ned Deily
Ned Deily n...@acm.org added the comment: Note, argparse is not part of the Python standard library in 2.6 but the 2.7 and 3.2 versions exhibit the same behavior. -- assignee: - bethard nosy: +bethard, ned.deily versions: +Python 2.7, Python 3.2 -Python 2.6