gh-117941: Fix argparse issue-Changed call method of BooleanOptionalAction class in argparse.py #117941#118103
gh-117941: Fix argparse issue-Changed call method of BooleanOptionalAction class in argparse.py #117941#118103jjpapa36912 wants to merge 2 commits intopython:mainfrom
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
I was wondering if when does it review. |
| @@ -0,0 +1 @@ | |||
| write! | |||
There was a problem hiding this comment.
Please see the devguide on how to write a NEWS entry.
Thank you for answer my question. I understand your explanation. But I think that to eliminating exception or abnormal situation is very important. In that sense, isn't it better to fix the code? |
|
If you can fix it properly, sure. It will not be easy. On the other hand, if we clearly say that adding |
Oh, thank you for your answer. I have one question. If the option string starts with "--no-" I think the current BoolOptionalAction always returns "False". What do you think about this? |
|
Right; I don't think that was the intent. >>> import argparse
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('--no-foo', default=True, action=argparse.BooleanOptionalAction)
>>> parser.parse_args()
Namespace(no_foo=True)
>>> parser.parse_args(['--no-foo'])
Namespace(no_foo=False)The documentation doesn't clearly say that this is wrong:
|
Uh oh!
There was an error while loading. Please reload this page.