[issue31768] argparse drops '|'s when the arguments are too long

paul j3 report at bugs.python.org
Thu Oct 12 15:48:11 EDT 2017


paul j3 <ajipanca at gmail.com> added the comment:

As documented in many other issues, the usage formatter is brittle.  It formats the individual usages, joins them into a string. Then if too long to fit on one line it tries t split into actions, etc.  This split produces an assertion error if there are 'wierd' characters in the names (e.g. #[]).

With mutually exclusive groups it gets even worse.  The brackets and | are spliced into the original string, and then excess [] and spaces are removed.  Once recent issue complained about its handling of nested groups (which are borderline wrong).

So I"m not surprised that a long group that spans a couple of lines gets messed up.   It requires a major rewrite, and even then I there will be formats involving groups that fall through the cracks.

----------
nosy: +paul.j3

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31768>
_______________________________________


More information about the Python-bugs-list mailing list