Message323458
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']) |
|
Date |
User |
Action |
Args |
2018-08-13 03:25:05 | Matthias Fripp | set | recipients:
+ Matthias Fripp |
2018-08-13 03:25:05 | Matthias Fripp | set | messageid: <1534130705.52.0.56676864532.issue34390@psf.upfronthosting.co.za> |
2018-08-13 03:25:05 | Matthias Fripp | link | issue34390 messages |
2018-08-13 03:25:04 | Matthias Fripp | create | |
|