From fe536f53ea1c4541e5297cea0c9460e5259cb1d8 Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Fri, 25 Apr 2008 16:59:09 +0000 Subject: [PATCH] Issue 2635: fix bug in the fix_sentence_endings option to textwrap.fill. --- Lib/test/test_textwrap.py | 4 ++++ Lib/textwrap.py | 1 + Misc/NEWS | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py index 787153e3cdf..c1c09f6a3ee 100644 --- a/Lib/test/test_textwrap.py +++ b/Lib/test/test_textwrap.py @@ -129,6 +129,10 @@ What a mess! expect = ['And she said, "Go to hell!" Can you believe that?'] self.check(wrapper.wrap(text), expect) + text = 'File stdio.h is nice.' + expect = ['File stdio.h is nice.'] + self.check(wrapper.wrap(text), expect) + def test_wrap_short(self): # Wrapping to make short lines longer diff --git a/Lib/textwrap.py b/Lib/textwrap.py index 473b98ac97f..ffbb9d16341 100644 --- a/Lib/textwrap.py +++ b/Lib/textwrap.py @@ -90,6 +90,7 @@ class TextWrapper: sentence_end_re = re.compile(r'[%s]' # lowercase letter r'[\.\!\?]' # sentence-ending punct. r'[\"\']?' # optional end-of-quote + r'\Z' # end of chunk % string.lowercase) diff --git a/Misc/NEWS b/Misc/NEWS index c616ba22852..9bd4f59ec80 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -43,6 +43,10 @@ Extensions Modules Library ------- +- Issue #2635: Fix bug in 'fix_sentence_endings' textwrap.fill option, + where an extra space was added after a word containing (but not + ending in) '.', '!' or '?'. + - Add from_buffer() and from_buffer_copy() class methods to ctypes data types