[New-bugs-announce] [issue16142] ArgumentParser inconsistent with parse_known_args

Idan Kamara report at bugs.python.org
Fri Oct 5 16:53:21 CEST 2012


New submission from Idan Kamara:

When known and unknown options are given together in the same option string (e.g. -xy) then ArgumentParser behaves in a strange way:

- if the known option is given first (so -k is known and the parser is fed with ['-ku']) then the parsing aborts with "error: argument -k/--known: ignored explicit argument 'u'"

- if the unknown option is given first then both options are treated as unknown and returned in the list of remaining arguments.

This makes it impossible to use parse_known_args for its intended purpose because every single letter option might be interleaved with other unknown options.

I attached a test script that demonstrates this.

----------
components: Library (Lib)
files: aparse.py
messages: 172088
nosy: idank
priority: normal
severity: normal
status: open
title: ArgumentParser inconsistent with parse_known_args
type: behavior
versions: Python 2.7, Python 3.3
Added file: http://bugs.python.org/file27434/aparse.py

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


More information about the New-bugs-announce mailing list