paul j3 added the comment:
This `argument_values` comes from `_get_values()`. Most of the time is derived
from the `argument_strings`. But in a few cases it is set to `action.default`,
specifically when the action is an optional postional with an empty
`argument_strings`.
test_argparse.TestMutuallyExclusiveOptionalAndPositional is such a case.
`badger` is an optional positional in a mutually exclusive group. As such it
can be 'present' without really being there (tricky). Positionals are always
processed - otherwise it raises an error.
If this is the case, what we need is a more reliable way of knowing whether
`_get_values()` is doing this, one that isn't fooled by this small int caching.
We could rewrite the `is not` test as:
if not argument_strings and action.nargs in ['*','?'] and argument_values
is action.default:
pass # _get_values() has set: argument_values=action.default
else:
seen_non_default_actions.add(action)
...
is a little better, but still feels like a kludge. Having `_get_values` return
a flag that says "I am actually returning action.default" would be clearer,
but, I think, too big of a change.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue18943>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com