-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-29298: Fix crash for required subparsers in argparse #18564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When an instance of subparsers is has required=True, and no subparser is found, an uncaught exception was thrown.
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). Recognized GitHub usernameWe couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames: This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
Codecov Report
@@ Coverage Diff @@
## master #18564 +/- ##
===========================================
+ Coverage 82.15% 83.13% +0.98%
===========================================
Files 1958 1571 -387
Lines 589837 414808 -175029
Branches 44458 44459 +1
===========================================
- Hits 484560 344844 -139716
+ Misses 95636 60337 -35299
+ Partials 9641 9627 -14
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR and welcome @BenSokol!
It looks like another open PR that addresses this issue (or another part of it) in #3680 is currently open and is not inactive (last comment from author 25 days ago). Does this crash still occur with their patch? At a glance, it looks like they address separate parts of the same BPO issue, but I'd like to be certain.
In the meantime, could you also include a new unit test for this in Lib/test/test_argparse.py
, to ensure that the fix functions as intended? This is typically needed for most PRs that make code changes in the standard library, particularly for bug fixes or ones that implement some new functionality. It helps to ensure that the fix works in the first place, and in the long term ensure that the issue remains fixed (to avoid regressions as much as possible).
Misc/NEWS.d/next/Library/2020-02-20-01-53-01.bpo-29298.laIn2S.rst
Outdated
Show resolved
Hide resolved
Co-Authored-By: Kyle Stanley <[email protected]>
@@ -0,0 +1,2 @@ | |||
Fix crash in :mod:`argparse` when using subparsers and its required attribute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
creash means segfault, not unhandled exception.
This was fixed in GH-3680, which includes tests. |
When an instance of subparsers is has required=True, and no subparser is found,
an uncaught exception was thrown.
OS: Windows - Cygwin
Python Version: 3.8.0b4
This issue still appears to be present in master
Fixes the following stack trace:
...
File "/usr/lib/python3.8/argparse.py", line 1760, in parse_args
args, argv = self.parse_known_args(args, namespace)
File "/usr/lib/python3.8/argparse.py", line 1792, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
File "/usr/lib/python3.8/argparse.py", line 2027, in _parse_known_args
', '.join(required_actions))
TypeError: sequence item 0: expected str instance, NoneType found
https://bugs.python.org/issue29298