Message317331
The bug is orthogonal, you can trigger it without the `required=` keyword argument via the (currently suggested) monkeypatch workaround which restores the pre-3.3 behaviour:
import argparse
parser = argparse.ArgumentParser()
subp = parser.add_subparsers()
subp.add_parser('test')
subp.required = True
parser.parse_args()
$ python3 test.py
Traceback (most recent call last):
File "test.py", line 7, in <module>
parser.parse_args()
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/argparse.py", line 1730, in parse_args
args, argv = self.parse_known_args(args, namespace)
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/argparse.py", line 1762, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/argparse.py", line 1997, in _parse_known_args
', '.join(required_actions))
TypeError: sequence item 0: expected str instance, NoneType found
Also note that when `dest` is specified it works fine:
import argparse
parser = argparse.ArgumentParser()
subp = parser.add_subparsers(dest='cmd')
subp.add_parser('test')
subp.required = True
parser.parse_args()
$ python3 test.py
usage: test.py [-h] {test} ...
test.py: error: the following arguments are required: cmd |
|
Date |
User |
Action |
Args |
2018-05-22 19:21:53 | Anthony Sottile | set | recipients:
+ Anthony Sottile, gregory.p.smith, bethard, ned.deily, eric.araujo, memeplex, paul.j3, serhiy.storchaka, wolma, bskinn |
2018-05-22 19:21:53 | Anthony Sottile | set | messageid: <1527016913.83.0.682650639539.issue33109@psf.upfronthosting.co.za> |
2018-05-22 19:21:53 | Anthony Sottile | link | issue33109 messages |
2018-05-22 19:21:53 | Anthony Sottile | create | |
|