[New-bugs-announce] [issue14364] Argparse incorrectly handles '--'

Michele Orrù report at bugs.python.org
Sun Mar 18 15:29:13 CET 2012


New submission from Michele Orrù <maker.py at gmail.com>:

http://docs.python.org/library/argparse.html#arguments-containing 
The attached file shows different behaviours when using '--' immediately after an optional argument.

tumbolandia:cpython maker$ python foo.py --test=-- foo 
[]
tumbolandia:cpython maker$ python foo.py --test -- foo 
usage: foo.py [-h] [-t TEST] [yuri]
foo.py: error: argument -t/--test: expected 1 argument(s)

The same is for single-dash arguments.

tumbolandia:cpython maker$ python foo.py -t -- foo
usage: foo.py [-h] [-t TEST] [yuri]
foo.py: error: argument -t/--test: expected 1 argument(s)
tumbolandia:cpython maker$ python foo.py -t-- foo
[]

Obviously argparse should return an error in both cases.
The  bug is probably due to Lib/argparser.py:2211

----------
files: foo.py
messages: 156254
nosy: maker
priority: normal
severity: normal
status: open
title: Argparse incorrectly handles '--'
versions: Python 2.7, Python 3.1
Added file: http://bugs.python.org/file24926/foo.py

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


More information about the New-bugs-announce mailing list