ysj.ray <ysj....@gmail.com> added the comment:

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.

----------
keywords: +patch
nosy: +ysj.ray
Added file: http://bugs.python.org/file21832/issue_11874.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11874>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to