[issue13107] Text width in optparse.py can become negative

Serhiy Storchaka report at bugs.python.org
Thu Aug 29 12:57:16 CEST 2013


Serhiy Storchaka added the comment:

Yes, argparse has same problem.

>>> import os, argparse
>>> p = argparse.ArgumentParser(prog='PROG')
>>> os.environ['COLUMNS'] = '16'
>>> print(p.format_help())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython/Lib/argparse.py", line 2329, in format_help
    return formatter.format_help()
  File "/home/serhiy/py/cpython/Lib/argparse.py", line 276, in format_help
    help = self._root_section.format_help()
  File "/home/serhiy/py/cpython/Lib/argparse.py", line 206, in format_help
    func(*args)
  File "/home/serhiy/py/cpython/Lib/argparse.py", line 206, in format_help
    func(*args)
  File "/home/serhiy/py/cpython/Lib/argparse.py", line 514, in _format_action
    help_lines = self._split_lines(help_text, help_width)
  File "/home/serhiy/py/cpython/Lib/argparse.py", line 614, in _split_lines
    return _textwrap.wrap(text, width)
  File "/home/serhiy/py/cpython/Lib/textwrap.py", line 355, in wrap
    return w.wrap(text)
  File "/home/serhiy/py/cpython/Lib/textwrap.py", line 300, in wrap
    return self._wrap_chunks(chunks)
  File "/home/serhiy/py/cpython/Lib/textwrap.py", line 227, in _wrap_chunks
    raise ValueError("invalid width %r (must be > 0)" % self.width)
ValueError: invalid width 0 (must be > 0)

----------
assignee: serhiy.storchaka -> 
versions: +Python 2.7, Python 3.3, Python 3.4

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


More information about the Python-bugs-list mailing list