[issue30754] textwrap.dedent mishandles empty lines

Emily Morehouse report at bugs.python.org
Mon Jun 26 21:27:51 EDT 2017


Emily Morehouse added the comment:

I concur with Martin, whitespace is not expected to be preserved on whitespace-only lines nor even considered when finding common leading whitepace. To illustrate this, see the examples below:

The following yields the same (expected) results:

    > python2 -c 'from textwrap import dedent; print repr(dedent(" " * 2 + "\n" + " " * 4 + "\t\n"))'
    > '\n\n'

And a simplified version of a test case from test_textwrap.py:

    > python2 -c 'from textwrap import dedent; print repr(dedent("  Foo\n \n"))'
    > 'Foo\n\n'

----------
nosy: +emilyemorehouse

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30754>
_______________________________________


More information about the Python-bugs-list mailing list