Message188869
'parse_fallback_args()' function is only in the 'test_intermixed.py' file, not the patch. It should be in the 'if __name__' section of that file, along with the modified 'exit()' method, since it is part of these testing suit, not meant to be imported. 'test_intermixed.py' is more of an example and discussion tool, not a formal test.
I added the '_fallback' optional argument because the normal exit from 'parse_args' using SystemExit is remarkably uninformative. It's hard to distinguish between the 'fallback' errors, and the ones generated by 'parse_known_args' (that have more to do with the argument strings). One is a programming error, the other a user generated error.
It is possible to redefine ArgumentParser.error() so it gives more information, for example by raising an Exception(message). I have added to test_intermixed.py an alternative 'parse_fallback_args' that uses such a modified error rather than the _fallback option. But that ends up modifying the normal parsing error generation as well.
I used the 'fallback' idea to test 'parse_intermixed_args' against the whole set 'test_argparse.py' tests. It would nice to have a way of doing that automatically anytime other features are added to 'parse_args'. But I can't think of a clean way of doing that.
Regarding earlier versions of these files - I do not see a way of deleting them.
I have attached a modified test_intermixed.py that has these changes. I also modified how 'parse_known_intermixed_args' restores the original value of self.usage, using an outer 'try:finally:' block. I need to make a note to myself to put that in the patch. |
|
Date |
User |
Action |
Args |
2013-05-10 19:38:01 | paul.j3 | set | recipients:
+ paul.j3, amcnabb, bethard, v+python, r.david.murray, docs@python, guilherme-pg |
2013-05-10 19:38:01 | paul.j3 | set | messageid: <1368214681.22.0.10713055322.issue14191@psf.upfronthosting.co.za> |
2013-05-10 19:38:01 | paul.j3 | link | issue14191 messages |
2013-05-10 19:38:01 | paul.j3 | create | |
|