[ python-Bugs-847346 ] textwrap ignoring fix_sentence_endings for
single lines
SourceForge.net
noreply at sourceforge.net
Sat Nov 22 14:12:00 EST 2003
Bugs item #847346, was opened at 2003-11-22 19:12
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=847346&group_id=5470
Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Tom Lynn (tlynn)
Assigned to: Nobody/Anonymous (nobody)
Summary: textwrap ignoring fix_sentence_endings for single lines
Initial Comment:
>>> import textwrap
>>> t=textwrap.
TextWrapper(fix_sentence_endings=True)
>>> print t.fill("A short line. Note the single space.")
A short line. Note the single space.
TextWrapper.wrap() is implemented as:
def wrap(self, text):
text = self._munge_whitespace(text)
indent = self.initial_indent
# *** Next line seems to be the bug ***
if len(text) + len(indent) <= self.width:
return [indent + text]
chunks = self._split(text)
if self.fix_sentence_endings:
self._fix_sentence_endings(chunks)
return self._wrap_chunks(chunks)
(if sf breaks the indentation, check the actual source!)
That early-return "if" clause seems to be an incorrect
optimisation which skips fix_sentence_endings.
Commenting it out seems to fix the problem.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=847346&group_id=5470
More information about the Python-bugs-list
mailing list