bpo-43874: fix argparse sub parser error when sub parser has no "name"#25446
bpo-43874: fix argparse sub parser error when sub parser has no "name"#25446terencehonles wants to merge 1 commit intopython:mainfrom
Conversation
This change updates the following crash to instead produce the error
message "%(prog)s: error: the following arguments are required: command".
Previously, when creating a simple required sub parser the following
will result in an error instead of an error message:
>>> from argparse import ArgumentParser
>>>
>>> parser = ArgumentParser()
>>> subparsers = parser.add_subparsers(required=True)
>>> subparsers.add_parser('one')
>>> subparsers.add_parser('two')
>>>
>>> parser.parse_args([])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.8/argparse.py", line 1768, in parse_args
args, argv = self.parse_known_args(args, namespace)
File "/usr/lib64/python3.8/argparse.py", line 1800, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
File "/usr/lib64/python3.8/argparse.py", line 2035, in _parse_known_args
', '.join(required_actions))
TypeError: sequence item 0: expected str instance, NoneType found
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
|
Looks like I had(?) to check if the CLA had been processed in order to have the bot update the labels. |
|
This PR is stale because it has been open for 30 days with no activity. |
|
bump |
|
I believe this is a duplicate of #3680, and it looks like that one took awhile to go through |
This change updates the following crash to instead produce the error message "%(prog)s: error: the following arguments are required: command".
Previously, when creating a simple required sub parser the following will result in an error instead of an error message:
https://bugs.python.org/issue43874