[New-bugs-announce] [issue17890] argparse: mutually exclusive groups full of suppressed args can cause AssertionErrors

Garrett Holmstrom report at bugs.python.org
Thu May 2 02:43:02 CEST 2013


New submission from Garrett Holmstrom:

When it goes to format a usage message, argparse seems to (correctly) fail to satisfy one of its assertions when all of the following are true:

1. A mutually exclusive group contains only args that are suppressed
2. An unsuppressed arg follows that group
3. The usage is long enough to need to line-wrap

The cause seems to be that the set of regular expressions that argparse uses to clean up mutually exclusive groups' separators doesn't handle the space that follows what would otherwise be an empty pair of square braces, sort of like this:

1. [-h] [ ] [--spam] ...
2. [-h] [] [--spam] ...
3. [-h]  [--spam] ...

A test case is attached.  I was able to reproduce this with python-2.7.3-13.fc18.x86_64 on Fedora as well as with commit 83588:e6b962fa44bb in 3.4 mainline.  I have a small patch for the latter that I'll submit shortly.

Sorry if I missed anything.  This is my first bug report against python proper.

----------
components: Library (Lib)
files: argparse-assertfail.py
messages: 188250
nosy: gholms
priority: normal
severity: normal
status: open
title: argparse: mutually exclusive groups full of suppressed args can cause AssertionErrors
type: behavior
versions: Python 2.7, Python 3.4
Added file: http://bugs.python.org/file30102/argparse-assertfail.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17890>
_______________________________________


More information about the New-bugs-announce mailing list