summaryrefslogtreecommitdiff
path: root/src/mailman/utilities/string.py
diff options
context:
space:
mode:
authorBarry Warsaw2015-12-29 17:23:54 -0500
committerBarry Warsaw2015-12-29 17:23:54 -0500
commit1602cecded07961585838a31758147e76584e957 (patch)
tree4e55d423f88424edabfc52eaa8c17357d57b296e /src/mailman/utilities/string.py
parent39fd2905cc34221ca2907f14f3f018190a3f62c5 (diff)
downloadmailman-1602cecded07961585838a31758147e76584e957.tar.gz
mailman-1602cecded07961585838a31758147e76584e957.tar.zst
mailman-1602cecded07961585838a31758147e76584e957.zip
Diffstat (limited to 'src/mailman/utilities/string.py')
-rw-r--r--src/mailman/utilities/string.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mailman/utilities/string.py b/src/mailman/utilities/string.py
index 478fd6574..4e7e5c0ad 100644
--- a/src/mailman/utilities/string.py
+++ b/src/mailman/utilities/string.py
@@ -117,8 +117,10 @@ def wrap(text, column=70, honor_leading_ws=True):
# This line does not constitute a paragraph break.
paragraph.append(line)
# We've consumed all the lines in the original text. Transfer the last
- # paragraph we were collecting to the full set of paragraphs.
- paragraphs.append(EMPTYSTRING.join(paragraph))
+ # paragraph we were collecting to the full set of paragraphs, but only if
+ # it's not empty.
+ if len(paragraph) > 0:
+ paragraphs.append(EMPTYSTRING.join(paragraph))
# Now iterate through all paragraphs, wrapping as necessary.
wrapped_paragraphs = []
# The dedented wrapper.
@@ -150,7 +152,7 @@ def wrap(text, column=70, honor_leading_ws=True):
# dedented. The leading whitespace on the first line of the
# original text will be used as the indentation for all lines
# in the wrapped text.
- for i, ch in enumerate(paragraph_text):
+ for i, ch in enumerate(paragraph_text): # pragma: no branch
if ch not in whitespace:
break
leading_ws = paragraph[:i]