[issue18723] shorten function of textwrap module is susceptible to non-normalized whitespaces

Vajrasky Kok report at bugs.python.org
Tue Aug 13 17:10:07 CEST 2013


Vajrasky Kok added the comment:

I missed this case:

>>> from textwrap import shorten
>>> shorten('hell', 4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sky/Code/python/programming_language/cpython/Lib/textwrap.py", line 386, in shorten
    return w.shorten(text, placeholder=placeholder)
  File "/home/sky/Code/python/programming_language/cpython/Lib/textwrap.py", line 322, in shorten
    raise ValueError("placeholder too large for max width")
ValueError: placeholder too large for max width

Also, in this patch, I removed the unnecessary stripping of the text part.

----------
Added file: http://bugs.python.org/file31277/fix_for_non_normalized_whitespaces_in_placeholder_v4.patch

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


More information about the Python-bugs-list mailing list