Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/textwrap.py

    r2 r391  
    66# Written by Greg Ward <gward@python.net>
    77
    8 __revision__ = "$Id: textwrap.py 68135 2009-01-01 15:46:10Z georg.brandl $"
     8__revision__ = "$Id$"
    99
    1010import string, re
     11
     12try:
     13    _unicode = unicode
     14except NameError:
     15    # If Python is built without Unicode support, the unicode type
     16    # will not exist. Fake one.
     17    class _unicode(object):
     18        pass
    1119
    1220# Do the right thing with boolean values for all known Python versions
     
    148156            if isinstance(text, str):
    149157                text = text.translate(self.whitespace_trans)
    150             elif isinstance(text, unicode):
     158            elif isinstance(text, _unicode):
    151159                text = text.translate(self.unicode_whitespace_trans)
    152160        return text
     
    157165
    158166        Split the text to wrap into indivisible chunks.  Chunks are
    159         not quite the same as words; see wrap_chunks() for full
     167        not quite the same as words; see _wrap_chunks() for full
    160168        details.  As an example, the text
    161169          Look, goof-ball -- use the -b option!
     
    168176        otherwise.
    169177        """
    170         if isinstance(text, unicode):
     178        if isinstance(text, _unicode):
    171179            if self.break_on_hyphens:
    172180                pat = self.wordsep_re_uni
     
    192200        """
    193201        i = 0
    194         pat = self.sentence_end_re
     202        patsearch = self.sentence_end_re.search
    195203        while i < len(chunks)-1:
    196             if chunks[i+1] == " " and pat.search(chunks[i]):
     204            if chunks[i+1] == " " and patsearch(chunks[i]):
    197205                chunks[i+1] = "  "
    198206                i += 2
Note: See TracChangeset for help on using the changeset viewer.