fixup! bpo-22433: do not consider "--foo='bar baz'" to be a positional argument
This commit is contained in:
parent
b6a18bb212
commit
6c2d2033f0
|
@ -2223,7 +2223,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
|||
if not self._has_negative_number_optionals:
|
||||
return None
|
||||
|
||||
# if it contains a space (before any equal sign), it was meant to be a positional
|
||||
# if it contains a space (before any equal sign), it was meant to be a
|
||||
# positional
|
||||
if ' ' in arg_string.split("=", 1)[0]:
|
||||
return None
|
||||
|
||||
|
|
|
@ -2022,7 +2022,7 @@ class TestAddSubparsers(TestCase):
|
|||
self.parser.parse_known_args(['0.5', '--opt="with space"']),
|
||||
(NS(foo=False, bar=0.5), ['--opt="with space"']),
|
||||
)
|
||||
self.assertRaisesRegexp(
|
||||
self.assertRaisesRegex(
|
||||
ArgumentParserError,
|
||||
"invalid choice: '--opt with space'",
|
||||
self.parser.parse_known_args,
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Fixed handling of "--foo='bar baz'" as non-positional argument with
|
||||
:mod:`argparse`.
|
Loading…
Reference in New Issue