Message190339
This is a refinement of the patch with Message188609.
In parse_known_intermixed_args, the temporary capture of formatted usage has been put in a try/finally structure.
Positionals are now 'deactivated' with
action.nargs = SUPPRESS
action.default = SUPPRESS
To use this, a 'nargs==SUPPRESS' case has been added to the relevant methods. In _get_args_pattern() it acts just like 'nargs=0'. In '_get_values()' it returns 'value=SUPPRESS'. The net effect is that, in take_action(), 'action' is not invoked, and that positional is not added to the namespace.
Previously I used nargs=0, which put a [] value in the namespace, which then had to be deleted.
I have not added anything about this SUPPRESS option to the documentation (PARSER isn't there either).
When the parser uses incompatible features (e.g. REMAINDER), this now raises a TypeError. The effect is similar to giving add_argument incompatible definitions. The 'fallback' that I used earlier can be implemented with a simple 'try/except TypeError'. Other parsing errors go through the usual ArgumentParser.error() method.
test_argparse.py has been changed to handle this TypeError. |
|
Date |
User |
Action |
Args |
2013-05-30 05:40:39 | paul.j3 | set | recipients:
+ paul.j3, amcnabb, bethard, v+python, r.david.murray, docs@python, guilherme-pg |
2013-05-30 05:40:38 | paul.j3 | set | messageid: <1369892438.91.0.461861579324.issue14191@psf.upfronthosting.co.za> |
2013-05-30 05:40:38 | paul.j3 | link | issue14191 messages |
2013-05-30 05:40:38 | paul.j3 | create | |
|