diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/argparse.py | 6 | ||||
-rw-r--r-- | Lib/test/test_argparse.py | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py index d2dcfdf..240625f 100644 --- a/Lib/argparse.py +++ b/Lib/argparse.py @@ -1997,7 +1997,11 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): # arguments, try to parse more single-dash options out # of the tail of the option string chars = self.prefix_chars - if arg_count == 0 and option_string[1] not in chars: + if ( + arg_count == 0 + and option_string[1] not in chars + and explicit_arg != '' + ): action_tuples.append((action, [], option_string)) char = option_string[0] option_string = char + explicit_arg[0] diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index 2b7f008..cabb2f8 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -296,7 +296,7 @@ class TestOptionalsSingleDashCombined(ParserTestCase): Sig('-z'), ] failures = ['a', '--foo', '-xa', '-x --foo', '-x -z', '-z -x', - '-yx', '-yz a', '-yyyx', '-yyyza', '-xyza'] + '-yx', '-yz a', '-yyyx', '-yyyza', '-xyza', '-x='] successes = [ ('', NS(x=False, yyy=None, z=None)), ('-x', NS(x=True, yyy=None, z=None)), |