New submission from Matthias Fripp <mfr...@gmail.com>:
The code below demonstrates this bug. import argparse parser = argparse.ArgumentParser() parser.add_argument('--list-arg', nargs='+', default=[]) parser.parse_known_args(['--list-arg', 'a', '--text-arg=hello world']) The result should be (Namespace(list_arg=['a']), ['--text-arg=hello world']), but is actually (Namespace(list_arg=['a', '--text-arg=hello world']), []). i.e., --list-arg consumes the next argument if that argument hasn't been defined and uses an equal sign and has a space in the assigned value. Note that both of the following work correctly: parser.parse_known_args(['--list-arg', 'a', '--text-arg', 'hello world']) parser.parse_known_args(['--list-arg', 'a', '--text-arg=hello']) Further, the next line should cause an error, but doesn't, due to the behavior noted above: parser.parse_args(['--list-arg', 'a', '--text-arg=hello world']) ---------- components: Library (Lib) messages: 323458 nosy: Matthias Fripp priority: normal severity: normal status: open title: arparse.ArgumentParser misparses list arguments followed by undefined arguments type: behavior versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34390> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com