[issue14364] Argparse incorrectly handles '--'

paul j3 report at bugs.python.org
Fri Apr 19 08:20:51 CEST 2013


paul j3 added the comment:

The patch that I  recently submitted for http://bugs.python.org/issue13922
appears to solve this issue.  It only removes the '--' that marked the end of options.  

With:

parser = argparse.ArgumentParser()
parser.add_argument('-f','--foo')
print(parser.parse_args(['-f--']))
print(parser.parse_args(['--foo=--']))
print(parser.parse_args(['-f', '--']))

I get:

Namespace(foo='--')
Namespace(foo='--')
usage: foodash.py [-h] [-f FOO]
foodash.py: error: argument -f/--foo: expected one argument

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14364>
_______________________________________


More information about the Python-bugs-list mailing list