Message201975
If a string contains an empty line and is using CRLF newlines instead of LF newlines textwrap.dedent doesn't work properly: it returns the original string w/o dedenting it.
As far as I can tell it's because it considers the empty string to be the longest common indent (http://hg.python.org/cpython/file/2.7/Lib/textwrap.py#l372, '[^ \t\n]' matches '\r').
Expected behavior: textwrap.dedent should work the same way whether lines are separated by a single LF character or by CRLF.
To repro:
✓ 15:26 dabovill @ morag in /tmp/dedent $ cat dedent.py
import textwrap
lf = '\ta\n\tb\n\n\tc'
crlf = '\ta\r\n\tb\r\n\r\n\tc'
print('- lf')
print(lf)
print('- dedent(lf)')
print(textwrap.dedent(lf))
print('- crlf')
print(crlf)
print('- dedent(crlf)')
print(textwrap.dedent(crlf))
✓ 15:26 dabovill @ morag in /tmp/dedent $ python2.7 dedent.py
- lf
a
b
c
- dedent(lf)
a
b
c
- crlf
a
b
c
- dedent(crlf)
a
b
c
✓ 15:26 dabovill @ morag in /tmp/dedent $ python3.3 dedent.py
- lf
a
b
c
- dedent(lf)
a
b
c
- crlf
a
b
c
- dedent(crlf)
a
b
c |
|
Date |
User |
Action |
Args |
2013-11-02 14:50:18 | alexis.d | set | recipients:
+ alexis.d |
2013-11-02 14:50:18 | alexis.d | set | messageid: <1383403818.41.0.713007913793.issue19479@psf.upfronthosting.co.za> |
2013-11-02 14:50:18 | alexis.d | link | issue19479 messages |
2013-11-02 14:50:17 | alexis.d | create | |
|