Closed as not planned
Closed as not planned
Description
Bug report
Bug description:
Code to recreate:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("args", nargs="*")
print(parser.parse_args())
Current behaviour:
If the wrong argument contains a space, it is added to the catch-all arguments:
> python bug.py --wrong-arg="foo bar"
Namespace(args=['--wrong-arg=foo bar'])
But if it doesn't contain a space, expected behaviour happens:
> python bug.py --wrong-arg="foobar"
usage: bug.py [-h] [args ...]
bug.py: error: unrecognized arguments: --wrong-arg=foobar
Expected behaviour:
Calling this program as bug.py --wrong-argument="foo bar"
prints an error message:
usage: bug.py [-h] [--name NAME] [args ...]
bug.py: error: unrecognized arguments: --wrong-arg=foo bar.
CPython versions tested on:
3.11
Operating systems tested on:
No response