This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ysj.ray
Recipients bethard, eric.araujo, htnieman, manveru, xuanji, ysj.ray
Date 2011-04-29.09:06:42
SpamBayes Score 4.5728925e-08
Marked as misclassified No
Message-id <1304068005.75.0.644940112365.issue11874@psf.upfronthosting.co.za>
In-reply-to
Content
Seem as a problem in optparse.HelpFormatter._format_usage(): when the generated usage string is too long(longer than 78, e.g.), python tries to break the usage string into parts at some proper positions and group them to multiple lines, then join the parts with space and assert it equal with original usage string. The regular expression used to break the usage string into parts is:
    """r'\(.*?\)+|\[.*?\]+|\S+'"""
So when there is '[]' in usage string, like in the example(there is '[]' in metavar), the assertion fails.

metavar="[LIB,]FBNAME" seems quite reasonable and usable, in the case that one want to define an option who has tow values and the first is optional. So I suggest '[]' should be allowed in metavar, and the _format_usage() needs fixed.

Here is a patch that fixes by changing the way breaking the usage string to parts and remove joining the parts and assert it equal to original usage string. Now the usage string is broken into intact each action of group usage strings. I think this breaking granularity is enough.
History
Date User Action Args
2011-04-29 09:06:46ysj.raysetrecipients: + ysj.ray, bethard, eric.araujo, xuanji, htnieman, manveru
2011-04-29 09:06:45ysj.raysetmessageid: <1304068005.75.0.644940112365.issue11874@psf.upfronthosting.co.za>
2011-04-29 09:06:43ysj.raylinkissue11874 messages
2011-04-29 09:06:43ysj.raycreate