]> granicus.if.org Git - python/commitdiff
Issue 2635: fix bug in the fix_sentence_endings option to textwrap.fill.
authorMark Dickinson <dickinsm@gmail.com>
Fri, 25 Apr 2008 16:59:09 +0000 (16:59 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Fri, 25 Apr 2008 16:59:09 +0000 (16:59 +0000)
Lib/test/test_textwrap.py
Lib/textwrap.py
Misc/NEWS

index 787153e3cdfbc589703dce675d79d189c4afbd5b..c1c09f6a3eede52183cec0f6ea94119cf41d5cd9 100644 (file)
@@ -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
 
index 473b98ac97f304dafdb8e3c151b1ff0b380a1471..ffbb9d16341014544757c74cc5df3d2808735e19 100644 (file)
@@ -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)
 
 
index c616ba228527d030e3b501a55be3d6b43d4e9499..9bd4f59ec80cd1deee760e54195057a69189f115 100644 (file)
--- 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