[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2021-10-27 Thread paul j3
paul j3 added the comment: A new patch, https://bugs.python.org/issue45235 has clobbered this patch. It has also exposed the inadequate unittesting for the case(s) where the 'dest' of main namespace, subparser namespace, user provided namespace overlap. -- __

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2020-07-14 Thread paul j3
paul j3 added the comment: I just realized if the subparser argument used default=argparse.SUPPRESS it would not clobber values (default or user) set by the main parser. (a 'store_true' would have to be replaced with a 'store_const' to do this) -- _

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2019-08-27 Thread hai shi
hai shi added the comment: How about use a flag(such USING_OUT_NAMESPACE) to identify we use namespace or not? For example: subnamespace, arg_strings = parser.parse_known_args(arg_strings, None) for key, value in vars(subnamespace).items(): if USING_OUT_NAMESPACE and not hasattr(namespace

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2019-05-10 Thread paul j3
paul j3 added the comment: A variation on the problem I reported in https://bugs.python.org/issue9351#msg229968 is that a custom Namespace class as documented in https://docs.python.org/3/library/argparse.html#the-namespace-object will not be used by the subparsers. Only the main parser

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2016-09-04 Thread paul j3
Changes by paul j3 : -- Removed message: http://bugs.python.org/msg274336 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsu

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2016-09-04 Thread paul j3
paul j3 added the comment: In http://bugs.python.org/issue27859 I've demonstrated how a subclass of _SubParsersAction can be used to revert the behavior to pre 2.7.9, passing the main namespace to the subparser. The only other change is to the parser registry: parser.register('action', 'p

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2016-09-03 Thread paul j3
paul j3 added the comment: Another example where the old way would have worked better http://bugs.python.org/issue27859 -- ___ Python tracker ___

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2015-06-03 Thread Rémi Rampin
Rémi Rampin added the comment: To me this is much more than a compatibility problem. The way it worked before made a lot of sense, and just felt like the "correct" solution to accept a flag in multiple places. Having a --verbose flag is something everybody should consider (Python has a decent

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2015-06-03 Thread smparkes
Changes by smparkes : -- nosy: +smparkes ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2015-06-03 Thread paul j3
paul j3 added the comment: Another example of this patch causing backward compatibility problems http://bugs.python.org/issue24251 -- ___ Python tracker ___ _

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2015-03-27 Thread Rémi Rampin
Changes by Rémi Rampin : -- nosy: +remram ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.or

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2014-12-23 Thread Changaco
Changaco added the comment: The broken patch made it into the 2.7.9 release, causing argparse to silently ignore arguments, cf http://bugs.python.org/issue23058 -- nosy: +Changaco ___ Python tracker ___

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2014-12-06 Thread R. David Murray
Changes by R. David Murray : -- resolution: fixed -> stage: commit review -> needs patch ___ Python tracker ___ ___ Python-bugs-list m

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2014-10-27 Thread R. David Murray
R. David Murray added the comment: If I understand you correctly, that would mean that if the namespace keyword is not used, we'd have the fixed behavior, but if the namespace keyword is used, we'd have the backward compatible behavior? If I'm understanding correctly, that sounds like a good

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2014-10-26 Thread paul j3
paul j3 added the comment: I'm exploring modifying that patch by adding a 'subnamespace' attribute to the subparsers Action object. This would give the user, or the main parser control over the namespace that is passed to a subparser. For example: subnamespace = getattr(self, 'subna

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2014-10-24 Thread R. David Murray
Changes by R. David Murray : -- stage: resolved -> commit review ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2014-10-24 Thread R. David Murray
R. David Murray added the comment: Yeah, I hesitated a bit about the backports, but didn't visualize the scenario you are suggesting and thought it would be safe. Perhaps it should be backed out of 2.7 and 3.4. For 3.5, do you have any thoughts about how to make namespace= play nicely with t

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2014-10-24 Thread paul j3
paul j3 added the comment: A possible problem with this patch is that it overrides any Namespace given by the user. In the test example: parser.parse_args(['X'], namespace=argparse.Namespace(foo=3)) the result is 'foo=2', the setdefault from the subparser. Previously, and with a single

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2014-10-17 Thread R. David Murray
R. David Murray added the comment: Thanks, Jyrki. -- nosy: +r.david.murray resolution: -> fixed stage: commit review -> resolved status: open -> closed versions: +Python 3.4, Python 3.5 -Python 3.2 ___ Python tracker

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2014-10-17 Thread Roundup Robot
Roundup Robot added the comment: New changeset e9cb45ccf42b by R David Murray in branch '3.4': #9351: set_defaults on subparser is no longer ignored if set on parent. https://hg.python.org/cpython/rev/e9cb45ccf42b New changeset b35a811d4420 by R David Murray in branch 'default': Merge: #9351: se

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2014-05-28 Thread paul j3
paul j3 added the comment: This is not getting much attention for several reasons: - there's quite a backlog of argparse patches and issues - 'set_defaults' is not commonly used. Setting default in 'add_argument' seems more common. - defining the same argument for both the parser and subpars

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2014-05-27 Thread paul j3
Changes by paul j3 : -- nosy: +paul.j3 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/m

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2013-12-27 Thread Mikael Knutsson
Mikael Knutsson added the comment: Just wanted to drop in here to let you know that I hit this behaviour recently when writing a small tool using both configparser and argparse and the workaround proves rather annoying (custom namespace object or similar). Would be awesome if this moved forwar

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2012-10-30 Thread Petri Lehtinen
Petri Lehtinen added the comment: LGTM. Steven? -- stage: needs patch -> commit review ___ Python tracker ___ ___ Python-bugs-list mail

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2012-10-30 Thread Jyrki Pulliainen
Changes by Jyrki Pulliainen : Removed file: http://bugs.python.org/file27794/issue9351.patch ___ Python tracker ___ ___ Python-bugs-list mailin

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2012-10-30 Thread Jyrki Pulliainen
Changes by Jyrki Pulliainen : Removed file: http://bugs.python.org/file27677/issue9351.patch ___ Python tracker ___ ___ Python-bugs-list mailin

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2012-10-30 Thread Jyrki Pulliainen
Changes by Jyrki Pulliainen : Added file: http://bugs.python.org/file27794/issue9351.patch ___ Python tracker ___ ___ Python-bugs-list mailing

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2012-10-30 Thread Jyrki Pulliainen
Changes by Jyrki Pulliainen : Added file: http://bugs.python.org/file27795/issue9351.patch ___ Python tracker ___ ___ Python-bugs-list mailing

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2012-10-30 Thread Jyrki Pulliainen
Changes by Jyrki Pulliainen : Removed file: http://bugs.python.org/file27793/issue9351.patch ___ Python tracker ___ ___ Python-bugs-list mailin

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2012-10-30 Thread Jyrki Pulliainen
Jyrki Pulliainen added the comment: Yeah, I tried figuring out something more clever, as this, in the current form, has a bit too hackish feeling in it, but I couldn't find a proper tool for the job. Anyway, attached a patch with the getattr removed. -- Added file: http://bugs.python.

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2012-10-29 Thread Petri Lehtinen
Petri Lehtinen added the comment: +for key in vars(subnamespace): +setattr(namespace, key, getattr(subnamespace, key)) There might be even more clever ways to achieve this, but what about at least saying "for key, value in vars(subnamespace).items()", and then using the valu

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2012-10-24 Thread Ezio Melotti
Changes by Ezio Melotti : -- nosy: +ezio.melotti ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyt

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2012-10-23 Thread Jyrki Pulliainen
Jyrki Pulliainen added the comment: I've attached a proposed fix where the subparser parses to an empty namespace and that namespace is then merged with the parent namespace -- keywords: +patch nosy: +nailor, petri.lehtinen Added file: http://bugs.python.org/file27677/issue9351.patch _

[issue9351] argparse set_defaults on subcommands should override top level set_defaults

2010-07-23 Thread Steven Bethard
New submission from Steven Bethard : If you use set_defaults on a subparser, but a default exists on the top level parser, the subparser defaults are ignored: >>> parser = argparse.ArgumentParser() >>> xparser = parser.add_subparsers().add_parser('X') >>> parser.set_defaults(foo=1) >>> xparser.