Message211229
| Author |
paul.j3 |
| Recipients |
arigo, bethard, paul.j3, pitrou |
| Date |
2014年02月14日.17:57:45 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1392400665.58.0.1412477939.issue18943@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
This patch corrects the handling of `seen_non_default_action` in another case - a positional with '?' and `type=int` (or other conversion).
if
parser.add_argument('badger', type=int, nargs='?', default=2) # or '2'
and the original test 'seen_non_default_actions' is:
if argument_values is not action.default
'argument_values' will be an 'int' regardless of the default. But it will pass the 'is' test with the (small) int default but not the string default.
With the patch proposed here, both defaults behave the same - 'badger' will not appear in 'seen_non_default_actions' if it did not occur in the argument_strings (i.e. match an empty string).
I may add case like this to `test_argparse.py` for this patch. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2014年02月14日 17:57:45 | paul.j3 | set | recipients:
+ paul.j3, arigo, pitrou, bethard |
| 2014年02月14日 17:57:45 | paul.j3 | set | messageid: <1392400665.58.0.1412477939.issue18943@psf.upfronthosting.co.za> |
| 2014年02月14日 17:57:45 | paul.j3 | link | issue18943 messages |
| 2014年02月14日 17:57:45 | paul.j3 | create |
|