bpo-30754: Document textwrap.dedent blank line behavior. (GH-14469)
![](https://secure.gravatar.com/avatar/cc7737cd64a84f1b5c61a160798e97ee.jpg?s=120&d=mm&r=g)
https://github.com/python/cpython/commit/3e133c401a51f08404b68f11d921f0b4062... commit: 3e133c401a51f08404b68f11d921f0b406283741 branch: 3.8 author: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> committer: GitHub <noreply@github.com> date: 2019-06-29T21:40:41-07:00 summary: bpo-30754: Document textwrap.dedent blank line behavior. (GH-14469) * Added documentation for textwrap.dedent behavior. * Remove an obsolete note about pre-2.5 behavior from the docstring. (cherry picked from commit eb97b9211e7c99841d6cae8c63893b3525d5a401) Co-authored-by: tmblweed <tmblweed@users.noreply.github.com> files: M Doc/library/textwrap.rst M Lib/textwrap.py diff --git a/Doc/library/textwrap.rst b/Doc/library/textwrap.rst index d254466c9a32..0f11ef401569 100644 --- a/Doc/library/textwrap.rst +++ b/Doc/library/textwrap.rst @@ -77,6 +77,9 @@ functions should be good enough; otherwise, you should use an instance of equal: the lines ``" hello"`` and ``"\thello"`` are considered to have no common leading whitespace. + Lines containing only whitespace are ignored in the input and normalized to a + single newline character in the output. + For example:: def test(): diff --git a/Lib/textwrap.py b/Lib/textwrap.py index 8103f347452d..30e693c8de03 100644 --- a/Lib/textwrap.py +++ b/Lib/textwrap.py @@ -420,9 +420,9 @@ def dedent(text): Note that tabs and spaces are both treated as whitespace, but they are not equal: the lines " hello" and "\\thello" are - considered to have no common leading whitespace. (This behaviour is - new in Python 2.5; older versions of this module incorrectly - expanded tabs before searching for common leading whitespace.) + considered to have no common leading whitespace. + + Entirely blank lines are normalized to a newline character. """ # Look for the longest leading string of spaces and tabs common to # all lines.
participants (1)
-
Miss Islington (bot)