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 evaned
Recipients Christophe.Guillon, Clint Olsen, abacabadabacaba, amcnabb, andersk, bethard, cben, danielsh, davidben, drm, eric.araujo, eric.smith, evaned, gdb, gfxmonk, martin.panter, memeplex, nelhage, paul.j3, r.david.murray, skilletaudio, spaceone
Date 2017-11-29.00:06:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I ran into this issue today. (Or rather a couple weeks ago, and I just diagnosed it today.)

Reading through the thread and from the bug's age it looks like a fix is probably not to promising, but Cherniavsky Beni's 2016-04-11 22:03 comment

> Can I additional suggest a change to the error message, e.g.:
>   $ prog --foo -bar
>   prog: error: argument --foo: expected one argument
>   (tip: use --foo=-bar to force interpretation as argument of --foo)
> This can be safely added in the current mode with no opt-in required,
> and will relieve the immediate "but what can I do?" confusions of 
> users.  The workaround is hard to discover otherwise, as `--foo=x` is 
> typically equivalent to `--foo x`.

and found it intriguing.

Messing around with the code, I was able to produce the attached patch, which, when run on the test case in the original comment, produces this output:

>>> import argparse
>>> parser = argparse.ArgumentParser(prog='a2x')
>>> parser.add_argument('--asciidoc-opts',
...     action='store', dest='asciidoc_opts', default='',
...     metavar='ASCIIDOC_OPTS', help='asciidoc options')
>>> parser.parse_args(['--asciidoc-opts', '--safe'])
usage: a2x [-h] [--asciidoc-opts ASCIIDOC_OPTS]
a2x: error: argument --asciidoc-opts: expected one argument (if you intended --safe to be the argument of --asciidoc-opts, pass --asciidoc-opts=--safe instead)

Would a cleaned-up version of this patch be of interest? (There are a couple obvious problems, like the out-of-bounds access to the list, PEP8, etc.) Is there some other way you could suggest to achieve this aim if you don't like that approach?

(I also think that nargs=## could maybe be special-cased to just ignore the A/O designation completely and only check there are enough, but I haven't tried this out. Does this seem like a viable approach? Would a patch that does that, subject to some flag, be of interest?)

The patch is relative to, I believe, the distribution version of 2.7.8. (Sorry, it's what I had handy as a custom build. :-) Updating it to .14 and to 3.whatever would be part of the cleanup.)
Date User Action Args
2017-11-29 00:06:11evanedsetrecipients: + evaned, cben, amcnabb, bethard, eric.smith, eric.araujo, r.david.murray, memeplex, gfxmonk, andersk, abacabadabacaba, gdb, nelhage, drm, davidben, martin.panter, paul.j3, skilletaudio, Christophe.Guillon, danielsh, spaceone, Clint Olsen
2017-11-29 00:06:11evanedsetmessageid: <>
2017-11-29 00:06:10evanedlinkissue9334 messages
2017-11-29 00:06:10evanedcreate