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 bgamari
Recipients bgamari
Date 2012-10-29.16:49:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1351529348.85.0.0475227022594.issue16360@psf.upfronthosting.co.za>
In-reply-to
Content
argparse suffers from a failing assertion when formatting a long usage message with an option whose metavar contains a comma. This can be seen in the attached testcase, which fails with,

Traceback (most recent call last):
  File "/home/ben/hi.py", line 24, in <module>
    args = parser.parse_args()
  File "/usr/lib/python2.7/argparse.py", line 1688, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib/python2.7/argparse.py", line 1720, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib/python2.7/argparse.py", line 1937, in _parse_known_args
    self.error(_('too few arguments'))
  File "/usr/lib/python2.7/argparse.py", line 2360, in error
    self.print_usage(_sys.stderr)
  File "/usr/lib/python2.7/argparse.py", line 2322, in print_usage
    self._print_message(self.format_usage(), file)
  File "/usr/lib/python2.7/argparse.py", line 2278, in format_usage
    return formatter.format_help()
  File "/usr/lib/python2.7/argparse.py", line 279, in format_help
    help = self._root_section.format_help()
  File "/usr/lib/python2.7/argparse.py", line 209, in format_help
    func(*args)
  File "/usr/lib/python2.7/argparse.py", line 330, in _format_usage
    assert ' '.join(opt_parts) == opt_usage
AssertionError

This failure is apparently due to a regular expression used to wrap  the usage message. The solution to this is unclear, but it seems to me using a regular expression here is a hack at best.
History
Date User Action Args
2012-10-29 16:49:08bgamarisetrecipients: + bgamari
2012-10-29 16:49:08bgamarisetmessageid: <1351529348.85.0.0475227022594.issue16360@psf.upfronthosting.co.za>
2012-10-29 16:49:08bgamarilinkissue16360 messages
2012-10-29 16:49:08bgamaricreate