This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vajrasky
Recipients pitrou, vajrasky
Date 2013-08-13.06:26:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1376375212.1.0.637444277248.issue18723@psf.upfronthosting.co.za>
In-reply-to
Content
In shorten function of textwrap module, the placeholder becomes a hole where we can inject non-normalized whitespaces to the text.

>>> text = "Hello there, how are you this fine day? I'm glad to hear it!"
>>> from textwrap import shorten
>>> shorten(text, 40, placeholder="              ")
'Hello there, how are you'

We normalize the only-whitespaces placeholder.

But....

>>> shorten(text, 17, placeholder="  \n\t(...)  \n\t[...]  \n\t")
'(...)  \n\t[...]'
>>> shorten(text, 40, placeholder="  \n\t(...)  \n\t[...]  \n\t")
'Hello there, how  \n\t(...)  \n\t[...]'

Attached the patch to normalize the non-normalized whitespaces in placeholder.
History
Date User Action Args
2013-08-13 06:26:52vajraskysetrecipients: + vajrasky, pitrou
2013-08-13 06:26:52vajraskysetmessageid: <1376375212.1.0.637444277248.issue18723@psf.upfronthosting.co.za>
2013-08-13 06:26:51vajraskylinkissue18723 messages
2013-08-13 06:26:51vajraskycreate