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

2014-01-09 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you Adam for your report. Thank you Elazar for your patch.

--
assignee:  -> serhiy.storchaka
resolution:  -> fixed
stage: patch review -> committed/rejected
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-01-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 779de7b4909b by Serhiy Storchaka in branch '2.7':
Issue #13107: argparse and optparse no longer raises an exception when output
http://hg.python.org/cpython/rev/779de7b4909b

New changeset c6c30b682e14 by Serhiy Storchaka in branch '3.3':
Issue #13107: argparse and optparse no longer raises an exception when output
http://hg.python.org/cpython/rev/c6c30b682e14

New changeset 48bcd03cd29f by Serhiy Storchaka in branch 'default':
Issue #13107: argparse and optparse no longer raises an exception when output
http://hg.python.org/cpython/rev/48bcd03cd29f

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-09-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is less ugly patch (for argparse and optparse). Instead of prohibiting 
wrapping at all for small width, it limits minimal width of formatted text. It 
try first decrease the indent for help.

--
stage: test needed -> patch review
Added file: http://bugs.python.org/file31735/argparse_less_ugly.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-09-11 Thread Elazar Gershuni

Elazar Gershuni added the comment:

ok. how about argparse_ugly.patch? below some width it simply won't do any 
wrapping.

(I hadn't touch optparse yet)

--
Added file: http://bugs.python.org/file31731/argparse_ugly.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-09-02 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> I think "ugly look is better than silence" here.

Agree. We have two possibilities:

1. Decrease an indentation. There is a lot of blank spaces below option's names.

2. Set some minimal width (10 or 20 characters) and let lines wrap out.

For better look we should use both methods.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-09-02 Thread Dmi Baranov

Dmi Baranov added the comment:

I think "ugly look is better than silence" here. Elazar, can you touch a 
optparse too (with some tests - test.support.EnvironmentVarGuard context 
manager will be helpful here)?

--
nosy: +dmi.baranov

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-09-01 Thread Elazar Gershuni

Elazar Gershuni added the comment:

I think in such case it is reasonable to fail silently, since the information 
will not be readable anyway.
Is a patch like the attached acceptable? (Sorry, I am new here)

results:

>>> import os, argparse; p = argparse.ArgumentParser(prog='PROG')
>>> os.environ['COLUMNS'] = '0'
>>> print(p.format_help())
usage: PROG
   
   [-h]

optional arguments:
  -h, --help  

>>>

--
keywords: +patch
nosy: +elazar
Added file: http://bugs.python.org/file31552/fixargparse.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-08-29 Thread Serhiy Storchaka

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 "", line 1, in 
  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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-08-26 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-08-17 Thread Ezio Melotti

Changes by Ezio Melotti :


--
keywords: +easy
stage: needs patch -> test needed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2011-10-09 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +aronacher, bethard

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2011-10-07 Thread Ezio Melotti

Ezio Melotti  added the comment:

argparse has some similar code in Lib/argparse.py:489.  Can you reproduce the 
problem with argparse?
If you can't and argparse solved the problem already, we might adopt the same 
solution; if you can, it should be fixed there too.

--
nosy: +ezio.melotti
stage:  -> needs patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2011-10-05 Thread Adam Byrtek

New submission from Adam Byrtek :

Code snippet from optparse.py:

   344 self.help_position = min(max_len + 2, self.max_help_position)
   345 self.help_width = self.width - self.help_position

Where self.width is initialized with the COLUMNS environment variable. On 
narrow terminals it can happen that self.help_position < self.width, leading to 
an exception in textwrap.py:

raise ValueError("invalid width %r (must be > 0)" % self.width)
ValueError: invalid width -15 (must be > 0)

A reasonable workaround would be to trim part of the help text instead of 
causing an exception.

--
components: Library (Lib)
messages: 144947
nosy: adambyrtek
priority: normal
severity: normal
status: open
title: Text width in optparse.py can become negative
type: behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com