This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Matthias Fripp
Recipients Matthias Fripp
Date 2018-08-13.03:25:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1534130705.52.0.56676864532.issue34390@psf.upfronthosting.co.za>
In-reply-to
Content
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'])
History
Date User Action Args
2018-08-13 03:25:05Matthias Frippsetrecipients: + Matthias Fripp
2018-08-13 03:25:05Matthias Frippsetmessageid: <1534130705.52.0.56676864532.issue34390@psf.upfronthosting.co.za>
2018-08-13 03:25:05Matthias Fripplinkissue34390 messages
2018-08-13 03:25:04Matthias Frippcreate