Issue 9355: argparse add_mutually_exclusive_group more than once has incorrectly formatted help (original) (raw)

Issue9355

Created on 2010-07-23 14:35 by bethard, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
argparse.diff ddowsett,2010-07-29 18:53 Patch for Issue9355 in HelpFormatter._format_actions_usage
test_mutually_exclusive.patch catherine,2010-08-04 20:24 review
mutually_exclusive_help.patch catherine,2010-08-04 20:26 copy of argparse.diff review
Messages (5)
msg111335 - (view) Author: Steven Bethard (bethard) * (Python committer) Date: 2010-07-23 14:35
[Moved from http://code.google.com/p/argparse/issues/detail?id=78] What steps will reproduce the problem? 1. Create two mutually exclusive groups: eg agroup = subcmd_parser.add_mutually_exclusive_group() agroup.add_argument('--a1', action='store_true', help='blah') agroup.add_argument('--a2', action='store_true', help='blah') agroup.add_argument('--a3', action='store_true', help='blah') bgroup = subcmd_parser.add_mutually_exclusive_group() bgroup.add_argument('--b1', action='store_true', help='blah') bgroup.add_argument('--b2', action='store_true', help='blah') bgroup.add_argument('--b3', action='store_true', help='blah') What is the expected output? What do you see instead? Expected output (on running a help command which formats help) is: [ --a1 | --a2 --a3 ] [ --b1 --b2 --b3 ] You see instead: [ --a1 --a2 --a3 [ --b1 --b2 --b3 ] Note that the closing brace for the first group is missing.
msg111987 - (view) Author: Drake Dowsett (ddowsett) Date: 2010-07-29 18:53
Problem is `inserts' dictionary is overwriting previous closing bracket, so checking for existing value and then appending if found.
msg112884 - (view) Author: Catherine Devlin (catherine) Date: 2010-08-04 20:24
Unit test for Drake's patch
msg112885 - (view) Author: Catherine Devlin (catherine) Date: 2010-08-04 20:26
copy of Drake's argparse.diff - same patch, just has less specific diff header info (because ``patch -p0 < argparse.diff`` failed on my machine)
msg120136 - (view) Author: Steven Bethard (bethard) * (Python committer) Date: 2010-11-01 16:31
Committed in r86092 (3.X) and r86093 (2.7). Thanks for the patches!
History
Date User Action Args
2022-04-11 14:57:04 admin set github: 53601
2010-12-21 10:36:28 bethard set nosy:bethard, ddowsett, catherinestage: needs patch -> resolved
2010-11-01 16:31:22 bethard set status: open -> closedassignee: bethardresolution: fixedmessages: +
2010-08-04 20:26:42 catherine set files: + mutually_exclusive_help.patchmessages: +
2010-08-04 20:24:46 catherine set files: + test_mutually_exclusive.patchnosy: + catherinemessages: +
2010-07-29 18:53:35 ddowsett set files: + argparse.diffversions: + Python 2.6nosy: + ddowsettmessages: + keywords: + patch
2010-07-23 14:35:22 bethard create