[New-bugs-announce] [issue15823] argparse produces error when multiply help lines

Nikolay Golub report at bugs.python.org
Thu Aug 30 16:14:22 CEST 2012


New submission from Nikolay Golub:

When i use this code:
  parser.add_argument('-r', '--range',
                        action = 'store',
                        dest = 'ranges',
                        nargs = 2,
                        metavar = 'RANGE',
                        required = False,
                        help = 'Start and end range date and time for report data.'\
                                'Timeformat is %y-%m-%d %H:%M:%S'\
                                'for example -r "2012-08-20 14:48:39 "2012-08-25 15:35:00"'
                        )

I get this error:


Traceback (most recent call last):
  File "./create_report.py", line 166, in <module>
    main()
  File "./create_report.py", line 123, in main
    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 1926, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/lib/python2.7/argparse.py", line 1866, in consume_optional
    take_action(action, args, option_string)
  File "/usr/lib/python2.7/argparse.py", line 1794, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/lib/python2.7/argparse.py", line 994, in __call__
    parser.print_help()
  File "/usr/lib/python2.7/argparse.py", line 2313, in print_help
    self._print_message(self.format_help(), file)
  File "/usr/lib/python2.7/argparse.py", line 2287, in format_help
    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 209, in format_help
    func(*args)
  File "/usr/lib/python2.7/argparse.py", line 515, in _format_action
    help_text = self._expand_help(action)
  File "/usr/lib/python2.7/argparse.py", line 601, in _expand_help
    return self._get_help_string(action) % params
ValueError: unsupported format character 'y' (0x79) at index 65

i think that it sin't normal. i always cut strings like these, according to pep8

----------
components: Library (Lib)
messages: 169456
nosy: Nikolay.Golub
priority: normal
severity: normal
status: open
title: argparse produces error when multiply help lines
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15823>
_______________________________________


More information about the New-bugs-announce mailing list