Message162617
| Author |
ncoghlan |
| Recipients |
ncoghlan |
| Date |
2012年06月11日.13:29:14 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1339421358.2.0.611530152115.issue15045@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
In working on #13857, I noticed that the current regex based implementation of textwrap.dedent() is limited specifically to ASCII whitespace (tabs and spaces) with Unix line endings (a line containing solely a Windows "\r\n" line ending will be deemed to contain a non-whitespace character, since "\r" isn't recognised by the regex)
The new textwrap.indent() function added in #13857 takes a much simpler approach to whitespace handling: its definition of a "line" is exactly that of "text.splitlines(True)", while its definition of a line that does not consist solely of whitespace is "bool(line.strip())"
As a simple example of how that can make a difference, consider:
>>> "\N{NO-BREAK SPACE}".strip()
''
One way to remedy this would be to replace the regex based implementation of textwrap.dedent with a simpler one written in terms of text.splitlines(True) and line.strip(). |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年06月11日 13:29:18 | ncoghlan | set | recipients:
+ ncoghlan |
| 2012年06月11日 13:29:18 | ncoghlan | set | messageid: <1339421358.2.0.611530152115.issue15045@psf.upfronthosting.co.za> |
| 2012年06月11日 13:29:16 | ncoghlan | link | issue15045 messages |
| 2012年06月11日 13:29:14 | ncoghlan | create |
|