Message404990
I haven't studied or tested this change, but it looks like a partial retraction of
https://bugs.python.org/issue9351
argparse set_defaults on subcommands should override top level set_defaults
Originally the main namespace was passed to the subparser. Steven Bethard changed it so that the subparser got a fresh namespace, and all values were copied to the main namespace.
I and others raised the question of how it affected user provided values
https://bugs.python.org/issue27859
argparse - subparsers does not retain namespace
Looks like this patch tries to solve some problems by moving the self._defaults step to the end of parser_know_args. I view that change with some trepidation. Handling defaults is tricky enough, with setting them at the start, but then only passing them through 'type' at the end if they still match the original strings.
Mostly I've been telling StackOverflow questioners that it best not to use the same argument 'dest' in both the main and subparsers. Flags can be the same, but the 'dest' should be different to avoid conflicts over which default has priority.
Again, I haven't tested this change, but I have a gut feeling it could have backward compatibility issues. |
|
Date |
User |
Action |
Args |
2021-10-25 18:16:15 | paul.j3 | set | recipients:
+ paul.j3, rhettinger, miss-islington, ALSchwalm |
2021-10-25 18:16:15 | paul.j3 | set | messageid: <1635185775.31.0.127064192707.issue45235@roundup.psfhosted.org> |
2021-10-25 18:16:15 | paul.j3 | link | issue45235 messages |
2021-10-25 18:16:15 | paul.j3 | create | |
|