New submission from Vajrasky Kok: 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. ---------- components: Library (Lib) files: fix_for_non_normalized_whitespaces_in_placeholder.patch keywords: patch messages: 195045 nosy: pitrou, vajrasky priority: normal severity: normal status: open title: shorten function of textwrap module is susceptible to non-normalized whitespaces type: behavior versions: Python 3.4 Added file: http://bugs.python.org/file31271/fix_for_non_normalized_whitespaces_in_placeholder.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18723> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com