Apply diff2.txt from SF patch http://www.python.org/sf/572113
(with one small bugfix in bgen/bgen/scantools.py)

This replaces string module functions with string methods
for the stuff in the Tools directory. Several uses of
string.letters etc. are still remaining.
diff --git a/Tools/scripts/byteyears.py b/Tools/scripts/byteyears.py
index f67be70..2b0f9b2 100755
--- a/Tools/scripts/byteyears.py
+++ b/Tools/scripts/byteyears.py
@@ -7,7 +7,6 @@
 # Options -[amc] select atime, mtime (default) or ctime as age.
 
 import sys, os, time
-import string
 from stat import *
 
 # Use lstat() to stat files if it exists, else stat()
@@ -51,7 +50,7 @@
         size = st[ST_SIZE]
         age = now - anytime
         byteyears = float(size) * float(age) / secs_per_year
-        print string.ljust(file, maxlen),
-        print string.rjust(`int(byteyears)`, 8)
+        print file.ljust(maxlen),
+        print repr(int(byteyears)).rjust(8)
 
 sys.exit(status)
diff --git a/Tools/scripts/checkappend.py b/Tools/scripts/checkappend.py
index c1188e2..b3141df 100755
--- a/Tools/scripts/checkappend.py
+++ b/Tools/scripts/checkappend.py
@@ -35,14 +35,13 @@
 
 import os
 import sys
-import string
 import getopt
 import tokenize
 
 verbose = 0
 
 def errprint(*args):
-    msg = string.join(args)
+    msg = ' '.join(args)
     sys.stderr.write(msg)
     sys.stderr.write("\n")
 
diff --git a/Tools/scripts/classfix.py b/Tools/scripts/classfix.py
index 26aa599..7b86aa3 100755
--- a/Tools/scripts/classfix.py
+++ b/Tools/scripts/classfix.py
@@ -156,8 +156,6 @@
 baseexpr = '^ *\(.*\) *( *) *$'
 baseprog = regex.compile(baseexpr)
 
-import string
-
 def fixline(line):
     if classprog.match(line) < 0: # No 'class' keyword -- no change
         return line
@@ -176,7 +174,7 @@
     basepart = line[a2+1:b2]
 
     # Extract list of base expressions
-    bases = string.splitfields(basepart, ',')
+    bases = basepart.split(',')
 
     # Strip trailing '()' from each base expression
     for i in range(len(bases)):
@@ -185,7 +183,7 @@
             bases[i] = bases[i][x1:y1]
 
     # Join the bases back again and build the new line
-    basepart = string.joinfields(bases, ', ')
+    basepart = ', '.join(bases)
 
     return head + '(' + basepart + '):' + tail
 
diff --git a/Tools/scripts/cvsfiles.py b/Tools/scripts/cvsfiles.py
index d133a40..2168556 100755
--- a/Tools/scripts/cvsfiles.py
+++ b/Tools/scripts/cvsfiles.py
@@ -14,7 +14,6 @@
 import sys
 import stat
 import getopt
-import string
 
 cutofftime = 0
 
@@ -51,7 +50,7 @@
     if cvsdir:
         entries = os.path.join(cvsdir, "Entries")
         for e in open(entries).readlines():
-            words = string.split(e, '/')
+            words = e.split('/')
             if words[0] == '' and words[1:]:
                 name = words[1]
                 fullname = os.path.join(dir, name)
diff --git a/Tools/scripts/dutree.py b/Tools/scripts/dutree.py
index 7a32533..35b3916 100755
--- a/Tools/scripts/dutree.py
+++ b/Tools/scripts/dutree.py
@@ -1,10 +1,10 @@
 #! /usr/bin/env python
 # Format du output in a tree shape
 
-import os, string, sys, errno
+import os, sys, errno
 
 def main():
-    p = os.popen('du ' + string.join(sys.argv[1:]), 'r')
+    p = os.popen('du ' + ' '.join(sys.argv[1:]), 'r')
     total, d = None, {}
     for line in p.readlines():
         i = 0
@@ -12,7 +12,7 @@
         size = eval(line[:i])
         while line[i] in ' \t': i = i+1
         file = line[i:-1]
-        comps = string.splitfields(file, '/')
+        comps = file.split('/')
         if comps[0] == '': comps[0] = '/'
         if comps[len(comps)-1] == '': del comps[len(comps)-1]
         total, d = store(size, comps, total, d)
@@ -51,7 +51,7 @@
         if tsub is None:
             psub = prefix
         else:
-            print prefix + string.rjust(`tsub`, width) + ' ' + key
+            print prefix + repr(tsub).rjust(width) + ' ' + key
             psub = prefix + ' '*(width-1) + '|' + ' '*(len(key)+1)
         if d.has_key(key):
             show(tsub, d[key][1], psub)
diff --git a/Tools/scripts/fixcid.py b/Tools/scripts/fixcid.py
index 6f674c6..8bc1de0 100755
--- a/Tools/scripts/fixcid.py
+++ b/Tools/scripts/fixcid.py
@@ -36,7 +36,6 @@
 
 import sys
 import regex
-import string
 import os
 from stat import *
 import getopt
@@ -213,11 +212,11 @@
 # Anything else is an operator -- don't list this explicitly because of '/*'
 
 OutsideComment = (Identifier, Number, String, Char, CommentStart)
-OutsideCommentPattern = '\(' + string.joinfields(OutsideComment, '\|') + '\)'
+OutsideCommentPattern = '\(' + '\|'.join(OutsideComment) + '\)'
 OutsideCommentProgram = regex.compile(OutsideCommentPattern)
 
 InsideComment = (Identifier, Number, CommentEnd)
-InsideCommentPattern = '\(' + string.joinfields(InsideComment, '\|') + '\)'
+InsideCommentPattern = '\(' + '\|'.join(InsideComment) + '\)'
 InsideCommentProgram = regex.compile(InsideCommentPattern)
 
 def initfixline():
@@ -286,10 +285,10 @@
         if not line: break
         lineno = lineno + 1
         try:
-            i = string.index(line, '#')
-        except string.index_error:
+            i = line.index('#')
+        except ValueError:
             i = -1          # Happens to delete trailing \n
-        words = string.split(line[:i])
+        words = line[:i].split()
         if not words: continue
         if len(words) == 3 and words[0] == 'struct':
             words[:2] = [words[0] + ' ' + words[1]]
diff --git a/Tools/scripts/fixheader.py b/Tools/scripts/fixheader.py
index ba2e0c5..1f9c713 100755
--- a/Tools/scripts/fixheader.py
+++ b/Tools/scripts/fixheader.py
@@ -3,7 +3,6 @@
 # Add some standard cpp magic to a header file
 
 import sys
-import string
 
 def main():
     args = sys.argv[1:]
@@ -29,8 +28,8 @@
     sys.stderr.write('Processing %s ...\n' % file)
     magic = 'Py_'
     for c in file:
-        if c in string.ascii_letters + string.digits:
-            magic = magic + string.upper(c)
+        if ord(c)<=0x80 and c.isalnum():
+            magic = magic + c.upper()
         else: magic = magic + '_'
     sys.stdout = f
     print '#ifndef', magic
diff --git a/Tools/scripts/ftpmirror.py b/Tools/scripts/ftpmirror.py
index 38af9dc..c3469d0 100755
--- a/Tools/scripts/ftpmirror.py
+++ b/Tools/scripts/ftpmirror.py
@@ -22,7 +22,6 @@
 import sys
 import time
 import getopt
-import string
 import ftplib
 import netrc
 from fnmatch import fnmatch
@@ -127,7 +126,7 @@
         if mac:
             # Mac listing has just filenames;
             # trailing / means subdirectory
-            filename = string.strip(line)
+            filename = line.strip()
             mode = '-'
             if filename[-1:] == '/':
                 filename = filename[:-1]
@@ -135,12 +134,12 @@
             infostuff = ''
         else:
             # Parse, assuming a UNIX listing
-            words = string.split(line, None, 8)
+            words = line.split(None, 8)
             if len(words) < 6:
                 if verbose > 1: print 'Skipping short line'
                 continue
-            filename = string.lstrip(words[-1])
-            i = string.find(filename, " -> ")
+            filename = words[-1].lstrip()
+            i = filename.find(" -> ")
             if i >= 0:
                 # words[0] had better start with 'l'...
                 if verbose > 1:
@@ -360,7 +359,7 @@
 def askabout(filetype, filename, pwd):
     prompt = 'Retrieve %s %s from %s ? [ny] ' % (filetype, filename, pwd)
     while 1:
-        reply = string.lower(string.strip(raw_input(prompt)))
+        reply = raw_input(prompt).strip().lower()
         if reply in ['y', 'ye', 'yes']:
             return 1
         if reply in ['', 'n', 'no', 'nop', 'nope']:
diff --git a/Tools/scripts/gencodec.py b/Tools/scripts/gencodec.py
index 69b6ede..46563df 100644
--- a/Tools/scripts/gencodec.py
+++ b/Tools/scripts/gencodec.py
@@ -22,7 +22,7 @@
 
 """#"
 
-import string,re,os,time,marshal
+import re,os,time,marshal
 
 # Create numeric tables or character based ones ?
 numeric = 1
@@ -34,9 +34,7 @@
                    '(#.+)?')
 
 def parsecodes(codes,
-
-               split=string.split,atoi=string.atoi,len=len,
-               filter=filter,range=range):
+               len=len, filter=filter,range=range):
 
     """ Converts code combinations to either a single code integer
         or a tuple of integers.
@@ -49,12 +47,12 @@
     """
     if not codes:
         return None
-    l = split(codes,'+')
+    l = codes.split('+')
     if len(l) == 1:
-        return atoi(l[0],16)
+        return int(l[0],16)
     for i in range(len(l)):
         try:
-            l[i] = atoi(l[i],16)
+            l[i] = int(l[i],16)
         except ValueError:
             l[i] = None
     l = filter(lambda x: x is not None, l)
@@ -63,9 +61,7 @@
     else:
         return tuple(l)
 
-def readmap(filename,
-
-            strip=string.strip):
+def readmap(filename):
 
     f = open(filename,'r')
     lines = f.readlines()
@@ -76,7 +72,7 @@
     for i in range(256):
         unmapped[i] = i
     for line in lines:
-        line = strip(line)
+        line = line.strip()
         if not line or line[0] == '#':
             continue
         m = mapRE.match(line)
@@ -108,9 +104,7 @@
 
     return enc2uni
 
-def hexrepr(t,
-
-            join=string.join):
+def hexrepr(t):
 
     if t is None:
         return 'None'
@@ -118,11 +112,9 @@
         len(t)
     except:
         return '0x%04x' % t
-    return '(' + join(map(lambda t: '0x%04x' % t, t),', ') + ')'
+    return '(' + ', '.join(map(lambda t: '0x%04x' % t, t)) + ')'
 
-def unicoderepr(t,
-
-                join=string.join):
+def unicoderepr(t):
 
     if t is None:
         return 'None'
@@ -133,11 +125,9 @@
             len(t)
         except:
             return repr(unichr(t))
-        return repr(join(map(unichr, t),''))
+        return repr(''.join(map(unichr, t)))
 
-def keyrepr(t,
-
-            join=string.join):
+def keyrepr(t):
 
     if t is None:
         return 'None'
@@ -151,7 +141,7 @@
                 return repr(chr(t))
             else:
                 return repr(unichr(t))
-        return repr(join(map(chr, t),''))
+        return repr(''.join(map(chr, t)))
 
 def codegen(name,map,comments=1):
 
@@ -246,7 +236,7 @@
 
 encoding_map = codecs.make_encoding_map(decoding_map)
 ''')
-    return string.join(l,'\n')
+    return '\n'.join(l)
 
 def pymap(name,map,pyfile,comments=1):
 
@@ -269,9 +259,9 @@
     mapnames = os.listdir(dir)
     for mapname in mapnames:
         name = os.path.split(mapname)[1]
-        name = string.replace(name,'-','_')
-        name = string.split(name, '.')[0]
-        name = string.lower(name)
+        name = name.replace('-','_')
+        name = name.split('.')[0]
+        name = name.lower()
         codefile = name + '.py'
         marshalfile = name + '.mapping'
         print 'converting %s to %s and %s' % (mapname,
diff --git a/Tools/scripts/ifdef.py b/Tools/scripts/ifdef.py
index da14437..c0c1459 100755
--- a/Tools/scripts/ifdef.py
+++ b/Tools/scripts/ifdef.py
@@ -29,7 +29,6 @@
 import sys
 import regex
 import getopt
-import string
 
 defs = []
 undefs = []
@@ -62,12 +61,12 @@
             nextline = fpi.readline()
             if not nextline: break
             line = line + nextline
-        tmp = string.strip(line)
+        tmp = line.strip()
         if tmp[:1] != '#':
             if ok: fpo.write(line)
             continue
-        tmp = string.strip(tmp[1:])
-        words = string.split(tmp)
+        tmp = tmp[1:].strip()
+        words = tmp.split()
         keyword = words[0]
         if keyword not in keywords:
             if ok: fpo.write(line)
diff --git a/Tools/scripts/logmerge.py b/Tools/scripts/logmerge.py
index d036749..d4c2fe6 100755
--- a/Tools/scripts/logmerge.py
+++ b/Tools/scripts/logmerge.py
@@ -24,7 +24,7 @@
 
 """
 
-import os, sys, getopt, string, re
+import os, sys, getopt, re
 
 sep1 = '='*77 + '\n'                    # file separator
 sep2 = '-'*28 + '\n'                    # revision separator
@@ -84,7 +84,7 @@
     keylen = len(key)
     for line in lines:
         if line[:keylen] == key:
-            working_file = string.strip(line[keylen:])
+            working_file = line[keylen:].strip()
             break
     else:
         working_file = None
@@ -93,7 +93,7 @@
         revline = lines[0]
         dateline = lines[1]
         text = lines[2:]
-        words = string.split(dateline)
+        words = dateline.split()
         author = None
         if len(words) >= 3 and words[0] == 'date:':
             dateword = words[1]
@@ -108,7 +108,7 @@
         else:
             date = None
             text.insert(0, revline)
-        words = string.split(revline)
+        words = revline.split()
         if len(words) >= 2 and words[0] == 'revision':
             rev = words[1]
         else:
diff --git a/Tools/scripts/mailerdaemon.py b/Tools/scripts/mailerdaemon.py
index 113b376..85f90aa 100755
--- a/Tools/scripts/mailerdaemon.py
+++ b/Tools/scripts/mailerdaemon.py
@@ -1,6 +1,5 @@
 """mailerdaemon - classes to parse mailer-daemon messages"""
 
-import string
 import rfc822
 import calendar
 import re
@@ -18,9 +17,9 @@
         sub = self.getheader('Subject')
         if not sub:
             return 0
-        sub = string.lower(sub)
-        if sub[:12] == 'waiting mail': return 1
-        if string.find(sub, 'warning') >= 0: return 1
+        sub = sub.lower()
+        if sub.startswith('waiting mail'): return 1
+        if 'warning' in sub: return 1
         self.sub = sub
         return 0
 
@@ -132,10 +131,10 @@
             if type(regexp) is type(''):
                 for i in range(len(emails)-1,-1,-1):
                     email = emails[i]
-                    exp = re.compile(string.join(string.split(regexp, '<>'), re.escape(email)), re.MULTILINE)
+                    exp = re.compile(re.escape(email).join(regexp.split('<>')), re.MULTILINE)
                     res = exp.search(data)
                     if res is not None:
-                        errors.append(string.join(string.split(string.strip(email)+': '+res.group('reason'))))
+                        errors.append(' '.join((email.strip()+': '+res.group('reason')).split()))
                         del emails[i]
                 continue
             res = regexp.search(data)
@@ -143,14 +142,14 @@
                 reason = res.group('reason')
                 break
     for email in emails:
-        errors.append(string.join(string.split(string.strip(email)+': '+reason)))
+        errors.append(' '.join((email.strip()+': '+reason).split()))
     return errors
 
 EMPARSERS = [emparse_list, ]
 
 def sort_numeric(a, b):
-    a = string.atoi(a)
-    b = string.atoi(b)
+    a = int(a)
+    b = int(b)
     if a < b: return -1
     elif a > b: return 1
     else: return 0
diff --git a/Tools/scripts/methfix.py b/Tools/scripts/methfix.py
index cbbb964..9e69961 100755
--- a/Tools/scripts/methfix.py
+++ b/Tools/scripts/methfix.py
@@ -30,7 +30,6 @@
 import regex
 import os
 from stat import *
-import string
 
 err = sys.stderr.write
 dbg = err
@@ -101,7 +100,7 @@
             return 1
         if lineno == 1 and g is None and line[:2] == '#!':
             # Check for non-Python scripts
-            words = string.split(line[2:])
+            words = line[2:].split()
             if words and regex.search('[pP]ython', words[0]) < 0:
                 msg = filename + ': ' + words[0]
                 msg = msg + ' script; not fixed\n'
diff --git a/Tools/scripts/nm2def.py b/Tools/scripts/nm2def.py
index fc1022a..6887ee2 100755
--- a/Tools/scripts/nm2def.py
+++ b/Tools/scripts/nm2def.py
@@ -34,7 +34,7 @@
 option to produce this format (since it is the original v7 Unix format).
 
 """
-import os,re,string,sys
+import os,re,sys
 
 PYTHONLIB = 'libpython'+sys.version[:3]+'.a'
 PC_PYTHONLIB = 'Python'+sys.version[0]+sys.version[2]+'.dll'
@@ -43,12 +43,12 @@
 def symbols(lib=PYTHONLIB,types=('T','C','D')):
 
     lines = os.popen(NM % lib).readlines()
-    lines = map(string.strip,lines)
+    lines = [s.strip() for s in lines]
     symbols = {}
     for line in lines:
         if len(line) == 0 or ':' in line:
             continue
-        items = string.split(line)
+        items = line.split()
         if len(items) != 3:
             continue
         address, type, name = items
@@ -69,7 +69,7 @@
     data.sort()
     data.append('')
     code.sort()
-    return string.join(data,' DATA\n')+'\n'+string.join(code,'\n')
+    return ' DATA\n'.join(data)+'\n'+'\n'.join(code)
 
 # Definition file template
 DEF_TEMPLATE = """\
diff --git a/Tools/scripts/objgraph.py b/Tools/scripts/objgraph.py
index e25e5b8..3e040b9 100755
--- a/Tools/scripts/objgraph.py
+++ b/Tools/scripts/objgraph.py
@@ -20,7 +20,6 @@
 
 
 import sys
-import string
 import os
 import getopt
 import regex
diff --git a/Tools/scripts/pathfix.py b/Tools/scripts/pathfix.py
index e1c6e73..81c5a6e 100755
--- a/Tools/scripts/pathfix.py
+++ b/Tools/scripts/pathfix.py
@@ -23,7 +23,6 @@
 import regex
 import os
 from stat import *
-import string
 import getopt
 
 err = sys.stderr.write
@@ -140,9 +139,9 @@
     return 0
 
 def fixline(line):
-    if line[:2] != '#!':
+    if not line.startswith('#!'):
         return line
-    if string.find(line, "python") < 0:
+    if "python" not in line:
         return line
     return '#! %s\n' % new_interpreter
 
diff --git a/Tools/scripts/pdeps.py b/Tools/scripts/pdeps.py
index 18b582b..1589709 100755
--- a/Tools/scripts/pdeps.py
+++ b/Tools/scripts/pdeps.py
@@ -23,7 +23,6 @@
 import sys
 import regex
 import os
-import string
 
 
 # Main program
@@ -82,10 +81,10 @@
         elif m_from.match(line) >= 0:
             (a, b), (a1, b1) = m_from.regs[:2]
         else: continue
-        words = string.splitfields(line[a1:b1], ',')
+        words = line[a1:b1].split(',')
         # print '#', line, words
         for word in words:
-            word = string.strip(word)
+            word = word.strip()
             if word not in list:
                 list.append(word)
 
@@ -152,7 +151,7 @@
     for mod in modules:
         list = table[mod]
         list.sort()
-        print string.ljust(mod, maxlen), ':',
+        print mod.ljust(maxlen), ':',
         if mod in list:
             print '(*)',
         for ref in list:
diff --git a/Tools/scripts/pindent.py b/Tools/scripts/pindent.py
index 318c20e..75175dc 100755
--- a/Tools/scripts/pindent.py
+++ b/Tools/scripts/pindent.py
@@ -83,7 +83,6 @@
 
 import os
 import re
-import string
 import sys
 
 next = {}
@@ -119,7 +118,7 @@
 
     def write(self, line):
         if self.expandtabs:
-            self._write(string.expandtabs(line, self.tabsize))
+            self._write(line.expandtabs(self.tabsize))
         else:
             self._write(line)
         # end if
@@ -270,7 +269,7 @@
                     thiskw = ''
                 # end if
             # end if
-            indent = len(string.expandtabs(line[:i], self.tabsize))
+            indent = len(line[:i].expandtabs(self.tabsize))
             while indent < current:
                 if firstkw:
                     if topid:
@@ -370,7 +369,7 @@
         return r
     # end def read
     def readline(self):
-        i = string.find(self.buf, '\n', self.pos)
+        i = self.buf.find('\n', self.pos)
         return self.read(i + 1 - self.pos)
     # end def readline
     def readlines(self):
@@ -514,9 +513,9 @@
             # end if
             action = 'reformat'
         elif o == '-s':
-            stepsize = string.atoi(a)
+            stepsize = int(a)
         elif o == '-t':
-            tabsize = string.atoi(a)
+            tabsize = int(a)
         elif o == '-e':
             expandtabs = 1
         # end if
diff --git a/Tools/scripts/rgrep.py b/Tools/scripts/rgrep.py
index 0271242..b644206 100755
--- a/Tools/scripts/rgrep.py
+++ b/Tools/scripts/rgrep.py
@@ -7,7 +7,6 @@
 
 import sys
 import re
-import string
 import getopt
 
 def main():
@@ -38,7 +37,7 @@
         pos = pos - size
         f.seek(pos)
         buffer = f.read(size)
-        lines = string.split(buffer, "\n")
+        lines = buffer.split("\n")
         del buffer
         if leftover is None:
             if not lines[-1]:
diff --git a/Tools/scripts/sum5.py b/Tools/scripts/sum5.py
index 3efcc74..4250dde 100755
--- a/Tools/scripts/sum5.py
+++ b/Tools/scripts/sum5.py
@@ -16,7 +16,6 @@
 """ % bufsize
 
 import sys
-import string
 import os
 import md5
 import regsub
@@ -89,7 +88,7 @@
         if o == '-t':
             rmode = 'r'
         if o == '-s':
-            bufsize = string.atoi(a)
+            bufsize = int(a)
     if not args: args = ['-']
     return sum(args, out)
 
diff --git a/Tools/scripts/trace.py b/Tools/scripts/trace.py
index f96e04f..38e985e 100644
--- a/Tools/scripts/trace.py
+++ b/Tools/scripts/trace.py
@@ -83,7 +83,7 @@
    trace.print_results(show_missing=1)
 """
 
-import sys, os, string, tempfile, types, copy, operator, inspect, exceptions, marshal
+import sys, os, tempfile, types, copy, operator, inspect, exceptions, marshal
 try:
     import cPickle
     pickle = cPickle
@@ -177,7 +177,7 @@
             # or
             #  d = "/usr/local.py"
             #  filename = "/usr/local.py"
-            if string.find(filename, d + os.sep) == 0:
+            if filename.startswith(d + os.sep):
                 self._ignore[modulename] = 1
                 return 1
 
@@ -341,13 +341,12 @@
                     # '#pragma: NO COVER' (it is possible to embed this into
                     # the text as a non-comment; no easy fix)
                     if executable_linenos.has_key(i+1) and \
-                       string.find(lines[i],
-                                   string.join(['#pragma', 'NO COVER'])) == -1:
+                       lines[i].find(' '.join(['#pragma', 'NO COVER'])) == -1:
                         outfile.write('>>>>>> ')
                     else:
                         outfile.write(' '*7)
                     n_lines = n_lines + 1
-                outfile.write(string.expandtabs(lines[i], 8))
+                outfile.write(lines[i].expandtabs(8))
 
             outfile.close()
 
@@ -675,16 +674,16 @@
             continue
 
         if opt == "--ignore-dir":
-            for s in string.split(val, os.pathsep):
+            for s in val.split(os.pathsep):
                 s = os.path.expandvars(s)
                 # should I also call expanduser? (after all, could use $HOME)
 
-                s = string.replace(s, "$prefix",
-                                   os.path.join(sys.prefix, "lib",
-                                                "python" + sys.version[:3]))
-                s = string.replace(s, "$exec_prefix",
-                                   os.path.join(sys.exec_prefix, "lib",
-                                                "python" + sys.version[:3]))
+                s = s.replace("$prefix",
+                              os.path.join(sys.prefix, "lib",
+                                           "python" + sys.version[:3]))
+                s = s.replace("$exec_prefix",
+                              os.path.join(sys.exec_prefix, "lib",
+                                           "python" + sys.version[:3]))
                 s = os.path.normpath(s)
                 ignore_dirs.append(s)
             continue
diff --git a/Tools/scripts/treesync.py b/Tools/scripts/treesync.py
index 96beba0..1064ab7 100755
--- a/Tools/scripts/treesync.py
+++ b/Tools/scripts/treesync.py
@@ -23,7 +23,7 @@
 
 """
 
-import os, sys, stat, string, getopt
+import os, sys, stat, getopt
 
 # Interactivity options
 default_answer = "ask"
@@ -97,7 +97,7 @@
     if cvsdir:
         entries = os.path.join(cvsdir, "Entries")
         for e in open(entries).readlines():
-            words = string.split(e, '/')
+            words = e.split('/')
             if words[0] == '' and words[1:]:
                 name = words[1]
                 s = os.path.join(slave, name)
@@ -188,10 +188,10 @@
     g.close()
 
 def okay(prompt, answer='ask'):
-    answer = string.lower(string.strip(answer))
+    answer = answer.strip().lower()
     if not answer or answer[0] not in 'ny':
         answer = raw_input(prompt)
-        answer = string.lower(string.strip(answer))
+        answer = answer.strip().lower()
         if not answer:
             answer = default_answer
     if answer[:1] == 'y':
diff --git a/Tools/scripts/untabify.py b/Tools/scripts/untabify.py
index 7be9f38..5eaf50e 100755
--- a/Tools/scripts/untabify.py
+++ b/Tools/scripts/untabify.py
@@ -4,7 +4,6 @@
 
 import os
 import sys
-import string
 import getopt
 
 def main():
@@ -32,7 +31,7 @@
     except IOError, msg:
         print "%s: I/O error: %s" % (`file`, str(msg))
         return
-    newtext = string.expandtabs(text, tabsize)
+    newtext = text.expandtabs(tabsize)
     if newtext == text:
         return
     backup = file + "~"
diff --git a/Tools/scripts/which.py b/Tools/scripts/which.py
index 96e242c..19e3203 100755
--- a/Tools/scripts/which.py
+++ b/Tools/scripts/which.py
@@ -7,13 +7,13 @@
 import sys
 if sys.path[0] in (".", ""): del sys.path[0]
 
-import sys, os, string
+import sys, os
 from stat import *
 
 def msg(str):
     sys.stderr.write(str + '\n')
 
-pathlist = string.splitfields(os.environ['PATH'], ':')
+pathlist = os.environ['PATH'].split(':')
 
 sts = 0
 longlist = ''
diff --git a/Tools/scripts/xxci.py b/Tools/scripts/xxci.py
index 2567bc5..681ce0b 100755
--- a/Tools/scripts/xxci.py
+++ b/Tools/scripts/xxci.py
@@ -9,7 +9,6 @@
 from stat import *
 import commands
 import fnmatch
-import string
 
 EXECMAGIC = '\001\140\000\010'
 
@@ -57,7 +56,7 @@
         f = open('.xxcign', 'r')
     except IOError:
         return
-    ignore[:] = ignore + string.split(f.read())
+    ignore[:] = ignore + f.read().split()
 
 def skipfile(file):
     for p in ignore: