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 mZarjk
Recipients bethard, mZarjk
Date 2014-09-09.03:22:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1410232931.16.0.457782886141.issue22363@psf.upfronthosting.co.za>
In-reply-to
Content
This assert statement is only reached when the usage line is long enough that it needs to be wrapped. Which is why the assertion does not happen when an argument is removed.

opt_usage is being compared to this string:
"[-h] [--arg2 ARG2] [--arg3 ARG3] [--arg4 ARG4] [--arg5 ARG5] [--arg6 ARG6]"

opt_usage in this case has the value:
"[-h]  [--arg2 ARG2] [--arg3 ARG3] [--arg4 ARG4] [--arg5 ARG5] [--arg6 ARG6]"

There is an extra space after "[-h]". The value of opt_usage comes from _format_actions_usage. And that is where the bug is.

Just before _format_actions_usage returns, the usage string is:
"[-h] [ ] [--arg2 ARG2] [--arg3 ARG3] [--arg4 ARG4] [--arg5 ARG5] [--arg6 ARG6]"

The method uses this regexp:
"[ *]"

To remove the extra brackets. But that leaves the extra space after the brackets.

The attached patch changes the regexp to:
"[ *] ?"

So that the extra space is also removed.

The patch also adds a testcase based on the script that reproduces the
History
Date User Action Args
2014-09-09 03:22:11mZarjksetrecipients: + mZarjk, bethard
2014-09-09 03:22:11mZarjksetmessageid: <1410232931.16.0.457782886141.issue22363@psf.upfronthosting.co.za>
2014-09-09 03:22:11mZarjklinkissue22363 messages
2014-09-09 03:22:10mZarjkcreate