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 DenKoren
Recipients DenKoren
Date 2014-09-17.15:57:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1410969476.15.0.703805216421.issue22433@psf.upfronthosting.co.za>
In-reply-to
Content
Argparse version 1.1 consider ANY unknown argument string containig ' ' (space character) as positional argument. As a result it can use such unknown optional argument as a value of known positional argument.

Demonstration code:

import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--known-optional-arg", "-k", action="store_true")
parser.add_argument("known_positional", action="store", type=str)
parser.parse_known_args(["--known-optional-arg", "--unknown-optional-arg=with spaces", "known positional arg"])
parser.parse_known_args(["--known-optional-arg", "--unknown-optional-arg=without_spaces", "known positional arg"])

Bugfix is attached to issue and affects ArgumentParser._parse_optional() method body.

Sorry, if it is a better way to report (or, possibly, fix) a bug than this place. It is my first python bug report.

Thanks.
History
Date User Action Args
2014-09-17 15:57:56DenKorensetrecipients: + DenKoren
2014-09-17 15:57:56DenKorensetmessageid: <1410969476.15.0.703805216421.issue22433@psf.upfronthosting.co.za>
2014-09-17 15:57:56DenKorenlinkissue22433 messages
2014-09-17 15:57:55DenKorencreate