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

Antoine Pitrou report at bugs.python.org
Tue Aug 13 17:34:16 CEST 2013


Antoine Pitrou 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

This is by design. Passing a placeholder larger than the width is a
programming error, regardless of whether the text is small enough.

----------
title: shorten function of textwrap module is susceptible to non-normalized whitespaces -> shorten function of textwrap module is susceptible to	non-normalized whitespaces

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


More information about the Python-bugs-list mailing list