[issue24338] In argparse adding wrong arguments makes malformed namespace

py.user report at bugs.python.org
Mon Jun 1 01:28:11 CEST 2015


py.user added the comment:

Serhiy Storchaka wrote:
> for example the use of such popular options as -0 or -@

Ok.

What about inconsistent conversion dashes to underscores?

>>> import argparse
>>> 
>>> parser = argparse.ArgumentParser(prefix_chars='@')
>>> _ = parser.add_argument('--x-one-two-three@')
>>> _ = parser.add_argument('@@y-one-two-three@')
>>> args = parser.parse_args(['abc'])
>>> args
Namespace(--x-one-two-three@='abc', y_one_two_three@=None)
>>>

We set dash as non-option char, but it continues to convert to underscore while another option char doesn't convert.

----------
status: pending -> open

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


More information about the Python-bugs-list mailing list