New submission from telmich: Using argparse with subparsers, the default behaviour if no subparser was selected, was to print help:
cdist% git describe 2.0.14-59-g5315c41 cdist% ./bin/cdist usage: cdist [-h] [-d] [-v] [-V] {banner,config} ... cdist: error: too few arguments cdist% python3 -V Python 3.2.3 With python 3.3.0, this changed and thus the so far uncalled code block is executed: cdist% ./bin/cdist Traceback (most recent call last): File "./bin/cdist", line 237, in <module> commandline() File "./bin/cdist", line 104, in commandline args.func(args) AttributeError: 'Namespace' object has no attribute 'func' cdist% git describe 2.0.14-59-g5315c41 cdist% python3 -V Python 3.3.0 Question: What is the correct way now to abort, if no subparser or no option was given (i.e. restore the previous behaviour)? I tried to fix this problem by using parser['main'].set_defaults(func=commandline_main) to setup a default handler for main, but this overwrites the func= parameter for all subparsers as well and thus renders this possibility useless (commits b7a8a84 and 840dbc5 in cdist). The source code for cdist using the subparsers is available at http://git.schottelius.org/?p=cdist ---------- components: Library (Lib) messages: 173659 nosy: telmich priority: normal severity: normal status: open title: Undocumented (?) behaviour change in argparse from 3.2.3 to 3.3.0 versions: Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue16308> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com