Ignore:
Timestamp:
Mar 19, 2014, 11:11:30 AM (11 years ago)
Author:
dmik
Message:

python: Update vendor to 2.7.6.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/vendor/current/Lib/re.py

    r2 r388  
    142142    return _compile(pattern, flags).search(string)
    143143
    144 def sub(pattern, repl, string, count=0):
     144def sub(pattern, repl, string, count=0, flags=0):
    145145    """Return the string obtained by replacing the leftmost
    146146    non-overlapping occurrences of the pattern in string by the
     
    149149    a callable, it's passed the match object and must return
    150150    a replacement string to be used."""
    151     return _compile(pattern, 0).sub(repl, string, count)
    152 
    153 def subn(pattern, repl, string, count=0):
     151    return _compile(pattern, flags).sub(repl, string, count)
     152
     153def subn(pattern, repl, string, count=0, flags=0):
    154154    """Return a 2-tuple containing (new_string, number).
    155155    new_string is the string obtained by replacing the leftmost
     
    160160    If it is a callable, it's passed the match object and must
    161161    return a replacement string to be used."""
    162     return _compile(pattern, 0).subn(repl, string, count)
    163 
    164 def split(pattern, string, maxsplit=0):
     162    return _compile(pattern, flags).subn(repl, string, count)
     163
     164def split(pattern, string, maxsplit=0, flags=0):
    165165    """Split the source string by the occurrences of the pattern,
    166166    returning a list containing the resulting substrings."""
    167     return _compile(pattern, 0).split(string, maxsplit)
     167    return _compile(pattern, flags).split(string, maxsplit)
    168168
    169169def findall(pattern, string, flags=0):
     
    199199    return _compile(pattern, flags|T)
    200200
    201 _alphanum = {}
    202 for c in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890':
    203     _alphanum[c] = 1
    204 del c
     201_alphanum = frozenset(
     202    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
    205203
    206204def escape(pattern):
     
    208206    s = list(pattern)
    209207    alphanum = _alphanum
    210     for i in range(len(pattern)):
    211         c = pattern[i]
     208    for i, c in enumerate(pattern):
    212209        if c not in alphanum:
    213210            if c == "\000":
Note: See TracChangeset for help on using the changeset viewer.