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

2013-10-16 Thread Vajrasky Kok
Vajrasky Kok added the comment: Serhiy's commit http://hg.python.org/cpython/rev/2e8c424dc638 fixed this issue already. So I closed this ticket. -- resolution: -> fixed status: open -> closed ___ Python tracker _

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

2013-08-13 Thread Vajrasky Kok
Vajrasky Kok added the comment: Okay, attached the fifth version not to care about the case where text is smaller than the placeholder. -- Added file: http://bugs.python.org/file31278/fix_for_non_normalized_whitespaces_in_placeholder_v5.patch ___ Py

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

2013-08-13 Thread Antoine Pitrou
Antoine Pitrou added the comment: > I missed this case: > > >>> from textwrap import shorten > >>> shorten('hell', 4) > Traceback (most recent call last): > File "", line 1, in > File > "/home/sky/Code/python/programming_language/cpython/Lib/textwrap.py", > line 386, in shorten > re

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

2013-08-13 Thread Vajrasky Kok
Vajrasky Kok added the comment: I missed this case: >>> from textwrap import shorten >>> shorten('hell', 4) Traceback (most recent call last): File "", line 1, in File "/home/sky/Code/python/programming_language/cpython/Lib/textwrap.py", line 386, in shorten return w.shorten(text, plac

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

2013-08-13 Thread Vajrasky Kok
Changes by Vajrasky Kok : Added file: http://bugs.python.org/file31276/fix_for_non_normalized_whitespaces_in_placeholder_v3.patch ___ Python tracker ___

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

2013-08-13 Thread Vajrasky Kok
Changes by Vajrasky Kok : Removed file: http://bugs.python.org/file31275/fix_for_non_normalized_whitespaces_in_placeholder_v3.patch ___ Python tracker ___ __

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

2013-08-13 Thread Vajrasky Kok
Vajrasky Kok added the comment: Attached more refined patch. Removed unnecessary test. Added more robust test. Added shorten in __all__. -- Added file: http://bugs.python.org/file31275/fix_for_non_normalized_whitespaces_in_placeholder_v3.patch ___ P

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

2013-08-13 Thread Vajrasky Kok
Vajrasky Kok added the comment: > Do you want to write a patch? My pleasure. Attached the second version of the patch to accomodate Pitrou's request. -- Added file: http://bugs.python.org/file31274/fix_for_non_normalized_whitespaces_in_placeholder_v2.patch

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

2013-08-13 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Isn't that weird? Agreed, this one is a bug. The stripping in shorten() should be smarter, i.e. it should not affect the placeholder's own spaces. Do you want to write a patch? -- ___ Python tracker

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

2013-08-13 Thread Antoine Pitrou
Antoine Pitrou added the comment: Correcting myself: > i.e. it should not affect the placeholder's own spaces. ... except for leading whitespace in case the placeholder ends up alone in the result. i.e. shorten("somethingtoolong") should return "(...)", not " (...)". -- _

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

2013-08-13 Thread Ezio Melotti
Changes by Ezio Melotti : -- nosy: +ezio.melotti stage: -> patch review ___ Python tracker ___ ___ Python-bugs-list mailing list Unsu

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

2013-08-12 Thread Vajrasky Kok
Vajrasky Kok added the comment: Okay, nevermind about non-normalized whitespaces in placeholder, but what about this case? >>> text = "Hello there, how are you this fine day? I'm glad to hear it!" >>> from textwrap import shorten >>> shorten(text, 10, placeholder=" ") 'Hello' >>> shorten(te

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

2013-08-12 Thread Antoine Pitrou
Antoine Pitrou added the comment: I'm not convinced this is a bug. The whitespace right-stripping is more of an implementation detail. You can really put what you want inside the placeholder. -- ___ Python tracker

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

2013-08-12 Thread Vajrasky Kok
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, p