From ea63e87a25a3c8dc86b1cd9c7dedf73d004b0eb6 Mon Sep 17 00:00:00 2001 From: Sushma Y Date: Wed, 12 Jun 2019 14:52:06 -0700 Subject: [PATCH 1/5] Added documentation for dedent behavior on issue 30754 --- Doc/library/textwrap.rst | 3 +++ Lib/textwrap.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Doc/library/textwrap.rst b/Doc/library/textwrap.rst index d254466c9a320d..f65f5eac67d223 100644 --- a/Doc/library/textwrap.rst +++ b/Doc/library/textwrap.rst @@ -76,6 +76,9 @@ functions should be good enough; otherwise, you should use an instance of 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. + + Lines containing only whitespace are ignored in the input and normalized to a + single newline character in the ouput. For example:: diff --git a/Lib/textwrap.py b/Lib/textwrap.py index 8103f347452d35..fe23ec868869a8 100644 --- a/Lib/textwrap.py +++ b/Lib/textwrap.py @@ -423,6 +423,8 @@ def dedent(text): 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.) + + Entirely blank lines are normalized to a newline character. """ # Look for the longest leading string of spaces and tabs common to # all lines. From 976bfc70c48afb9dc972797298ab56b6fde796a1 Mon Sep 17 00:00:00 2001 From: Sushma Y Date: Tue, 18 Jun 2019 11:31:14 -0700 Subject: [PATCH 2/5] fix typo --- Doc/library/textwrap.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/textwrap.rst b/Doc/library/textwrap.rst index f65f5eac67d223..6f665f7c5a233d 100644 --- a/Doc/library/textwrap.rst +++ b/Doc/library/textwrap.rst @@ -78,7 +78,7 @@ functions should be good enough; otherwise, you should use an instance of common leading whitespace. Lines containing only whitespace are ignored in the input and normalized to a - single newline character in the ouput. + single newline character in the output. For example:: From e2082453c469bcd4a99d586091b46987f2dba6f7 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Sat, 29 Jun 2019 17:11:28 -0700 Subject: [PATCH 3/5] removed trailing whitespace --- Doc/library/textwrap.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/textwrap.rst b/Doc/library/textwrap.rst index 6f665f7c5a233d..0f11ef401569de 100644 --- a/Doc/library/textwrap.rst +++ b/Doc/library/textwrap.rst @@ -76,8 +76,8 @@ functions should be good enough; otherwise, you should use an instance of 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. - - Lines containing only whitespace are ignored in the input and normalized to a + + Lines containing only whitespace are ignored in the input and normalized to a single newline character in the output. For example:: From 37fbbd67224e4a59ea275aa2fff8ba0e51f504b0 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Sat, 29 Jun 2019 17:16:40 -0700 Subject: [PATCH 4/5] Remove an obsolete comment about pre-2.5 behavior. Docstrings do not need to describe things from 15 years ago. (I only noticed this due to the diff) --- Lib/textwrap.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Lib/textwrap.py b/Lib/textwrap.py index fe23ec868869a8..7c6a8caf31b6b6 100644 --- a/Lib/textwrap.py +++ b/Lib/textwrap.py @@ -420,9 +420,7 @@ 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. """ From 89285f191610e99dcfd5f2550123eb89b10bc182 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Sat, 29 Jun 2019 18:20:12 -0700 Subject: [PATCH 5/5] remove trailing whitespace --- Lib/textwrap.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/textwrap.py b/Lib/textwrap.py index 7c6a8caf31b6b6..30e693c8de0354 100644 --- a/Lib/textwrap.py +++ b/Lib/textwrap.py @@ -421,8 +421,8 @@ 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. - - Entirely blank lines are normalized to a newline character. + + Entirely blank lines are normalized to a newline character. """ # Look for the longest leading string of spaces and tabs common to # all lines.