Anonymous avatar Anonymous committed 450d604

Move 2.0 changes collected in branches/pending back to trunk for further
development. Note that this set of changes is NOT backward-compatible;
the trunk no longer works with Python 1.5.2, 2.0, or 2.1.

Comments (0)

Files changed (499)

QMTest/SConscript

 #
 
 import os.path
-import string
 
 Import('build_dir', 'env')
 
     # Note:  We construct the __ VERSION __ substitution string at
     # run-time so it doesn't get replaced when this file gets copied
     # into the tree for packaging.
-    c = string.replace(c, '__' + 'VERSION' + '__', env['VERSION'])
+    c = c.replace('__' + 'VERSION' + '__', env['VERSION'])
     open(t, 'wb').write(c)
 
 for file in files:

QMTest/TestCmd.py

 # PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
 # AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+from __future__ import generators  ### KEEP FOR COMPATIBILITY FIXERS
 
 __author__ = "Steven Knight <knight at baldmt dot com>"
 __revision__ = "TestCmd.py 0.37.D001 2010/01/11 16:55:50 knight"
 import re
 import shutil
 import stat
-import string
 import sys
 import tempfile
 import time
 
 def _clean():
     global _Cleanup
-    cleanlist = filter(None, _Cleanup)
+    cleanlist = [_f for _f in _Cleanup if _f]
     del _Cleanup[:]
     cleanlist.reverse()
     for test in cleanlist:
 except NameError:
     def zip(*lists):
         result = []
-        for i in xrange(min(map(len, lists))):
-            result.append(tuple(map(lambda l, i=i: l[i], lists)))
+        for i in xrange(min(list(map(len, lists)))):
+            result.append(tuple([l[i] for l in lists]))
         return result
 
 class Collector:
     def __init__(self, top):
         self.entries = [top]
     def __call__(self, arg, dirname, names):
-        pathjoin = lambda n, d=dirname: os.path.join(d, n)
-        self.entries.extend(map(pathjoin, names))
+        pathjoin = lambda n: os.path.join(dirname, n)
+        self.entries.extend(list(map(pathjoin, names)))
 
 def _caller(tblist, skip):
     string = ""
     """
     """
     if not is_List(lines):
-        lines = string.split(lines, "\n")
+        lines = lines.split("\n")
     if not is_List(matches):
-        matches = string.split(matches, "\n")
+        matches = matches.split("\n")
     if len(lines) != len(matches):
         return
     for i in range(len(lines)):
     """
     """
     if not is_List(lines):
-        lines = string.split(lines, "\n")
+        lines = lines.split("\n")
     if not is_List(res):
-        res = string.split(res, "\n")
+        res = res.split("\n")
     if len(lines) != len(res):
         return
     for i in range(len(lines)):
     """
     """
     if not type(lines) is type(""):
-        lines = string.join(lines, "\n")
+        lines = "\n".join(lines)
     if not type(res) is type(""):
-        res = string.join(res, "\n")
+        res = "\n".join(res)
     s = "^" + res + "$"
     try:
         expr = re.compile(s, re.DOTALL)
         for op, a1, a2, b1, b2 in sm.get_opcodes():
             if op == 'delete':
                 result.append("%sd%d" % (comma(a1, a2), b1))
-                result.extend(map(lambda l: '< ' + l, a[a1:a2]))
+                result.extend(['< ' + l for l in a[a1:a2]])
             elif op == 'insert':
                 result.append("%da%s" % (a1, comma(b1, b2)))
-                result.extend(map(lambda l: '> ' + l, b[b1:b2]))
+                result.extend(['> ' + l for l in b[b1:b2]])
             elif op == 'replace':
                 result.append("%sc%s" % (comma(a1, a2), comma(b1, b2)))
-                result.extend(map(lambda l: '< ' + l, a[a1:a2]))
+                result.extend(['< ' + l for l in a[a1:a2]])
                 result.append('---')
-                result.extend(map(lambda l: '> ' + l, b[b1:b2]))
+                result.extend(['> ' + l for l in b[b1:b2]])
         return result
 
 def diff_re(a, b, fromfile='', tofile='',
         if path is None:
             path = os.environ['PATH']
         if is_String(path):
-            path = string.split(path, os.pathsep)
+            path = path.split(os.pathsep)
         if pathext is None:
             pathext = os.environ['PATHEXT']
         if is_String(pathext):
-            pathext = string.split(pathext, os.pathsep)
+            pathext = pathext.split(os.pathsep)
         for ext in pathext:
-            if string.lower(ext) == string.lower(file[-len(ext):]):
+            if ext.lower() == file[-len(ext):].lower():
                 pathext = ['']
                 break
         for dir in path:
         if path is None:
             path = os.environ['PATH']
         if is_String(path):
-            path = string.split(path, os.pathsep)
+            path = path.split(os.pathsep)
         for dir in path:
             f = os.path.join(dir, file)
             if os.path.isfile(f):
             universal_newlines = 1
             def __init__(self, command, **kw):
                 if kw.get('stderr') == 'STDOUT':
-                    apply(popen2.Popen4.__init__, (self, command, 1))
+                    popen2.Popen4.__init__(self, command, 1)
                 else:
-                    apply(popen2.Popen3.__init__, (self, command, 1))
+                    popen2.Popen3.__init__(self, command, 1)
                 self.stdin = self.tochild
                 self.stdout = self.fromchild
                 self.stderr = self.childerr
             def wait(self, *args, **kw):
-                resultcode = apply(popen2.Popen3.wait, (self,)+args, kw)
+                resultcode = popen2.Popen3.wait(self, *args, **kw)
                 if os.WIFEXITED(resultcode):
                     return os.WEXITSTATUS(resultcode)
                 elif os.WIFSIGNALED(resultcode):
                 #self.diff_function = difflib.unified_diff
         self._dirlist = []
         self._preserve = {'pass_test': 0, 'fail_test': 0, 'no_result': 0}
-        if os.environ.has_key('PRESERVE') and not os.environ['PRESERVE'] is '':
+        if 'PRESERVE' in os.environ and not os.environ['PRESERVE'] is '':
             self._preserve['pass_test'] = os.environ['PRESERVE']
             self._preserve['fail_test'] = os.environ['PRESERVE']
             self._preserve['no_result'] = os.environ['PRESERVE']
             slash = '\\'
             special = '"$'
 
-            arg = string.replace(arg, slash, slash+slash)
+            arg = arg.replace(slash, slash+slash)
             for c in special:
-                arg = string.replace(arg, c, slash+c)
+                arg = arg.replace(c, slash+c)
 
             if re_space.search(arg):
                 arg = '"' + arg + '"'
 
     def canonicalize(self, path):
         if is_List(path):
-            path = apply(os.path.join, tuple(path))
+            path = os.path.join(*tuple(path))
         if not os.path.isabs(path):
             path = os.path.join(self.workdir, path)
         return path
             cmd = list(interpreter) + cmd
         if arguments:
             if type(arguments) == type(''):
-                arguments = string.split(arguments)
+                arguments = arguments.split()
             cmd.extend(arguments)
         return cmd
 
         def diff(self, a, b, name, *args, **kw):
             print self.banner(name)
             args = (a.splitlines(), b.splitlines()) + args
-            lines = apply(self.diff_function, args, kw)
+            lines = self.diff_function(*args, **kw)
             for l in lines:
                 print l
 
         prepended unless it is enclosed in a [list].
         """
         cmd = self.command_args(program, interpreter, arguments)
-        cmd_string = string.join(map(self.escape, cmd), ' ')
+        cmd_string = ' '.join(map(self.escape, cmd))
         if self.verbose:
             sys.stderr.write(cmd_string + "\n")
         if universal_newlines is None:
             if sub is None:
                 continue
             if is_List(sub):
-                sub = apply(os.path.join, tuple(sub))
+                sub = os.path.join(*tuple(sub))
             new = os.path.join(self.workdir, sub)
             try:
                 os.mkdir(new)
         # letters is pretty much random on win32:
         drive,rest = os.path.splitdrive(path)
         if drive:
-            path = string.upper(drive) + rest
+            path = drive.upper() + rest
 
         #
         self._dirlist.append(path)
         """Find an executable file.
         """
         if is_List(file):
-            file = apply(os.path.join, tuple(file))
+            file = os.path.join(*tuple(file))
         if not os.path.isabs(file):
             file = where_is(file, path, pathext)
         return file
         the temporary working directory name with the specified
         arguments using the os.path.join() method.
         """
-        return apply(os.path.join, (self.workdir,) + tuple(args))
+        return os.path.join(self.workdir, *tuple(args))
 
     def readable(self, top, read=1):
         """Make the specified directory tree readable (read == 1)

QMTest/TestCommon.py

 # PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
 # AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+from __future__ import generators  ### KEEP FOR COMPATIBILITY FIXERS
 
 __author__ = "Steven Knight <knight at baldmt dot com>"
 __revision__ = "TestCommon.py 0.37.D001 2010/01/11 16:55:50 knight"
 import os
 import os.path
 import stat
-import string
 import sys
 import types
 import UserList
     lib_suffix   = '.a'
     dll_prefix   = ''
     dll_suffix   = '.dll'
-elif string.find(sys.platform, 'irix') != -1:
+elif sys.platform.find('irix') != -1:
     exe_suffix   = ''
     obj_suffix   = '.o'
     shobj_suffix = '.o'
     lib_suffix   = '.a'
     dll_prefix   = 'lib'
     dll_suffix   = '.so'
-elif string.find(sys.platform, 'darwin') != -1:
+elif sys.platform.find('darwin') != -1:
     exe_suffix   = ''
     obj_suffix   = '.o'
     shobj_suffix = '.os'
     lib_suffix   = '.a'
     dll_prefix   = 'lib'
     dll_suffix   = '.dylib'
-elif string.find(sys.platform, 'sunos') != -1:
+elif sys.platform.find('sunos') != -1:
     exe_suffix   = ''
     obj_suffix   = '.o'
     shobj_suffix = '.os'
         calling the base class initialization, and then changing directory
         to the workdir.
         """
-        apply(TestCmd.__init__, [self], kw)
+        TestCmd.__init__(self, **kw)
         os.chdir(self.workdir)
 
     def must_be_writable(self, *files):
         them.  Exits FAILED if any of the files does not exist or is
         not writable.
         """
-        files = map(lambda x: is_List(x) and apply(os.path.join, x) or x, files)
+        files = [is_List(x) and os.path.join(*x) or x for x in files]
         existing, missing = separate_files(files)
-        unwritable = filter(lambda x, iw=is_writable: not iw(x), existing)
+        unwritable = [x for x in existing if not is_writable(x)]
         if missing:
-            print "Missing files: `%s'" % string.join(missing, "', `")
+            print "Missing files: `%s'" % "', `".join(missing)
         if unwritable:
-            print "Unwritable files: `%s'" % string.join(unwritable, "', `")
+            print "Unwritable files: `%s'" % "', `".join(unwritable)
         self.fail_test(missing + unwritable)
 
     def must_contain(self, file, required, mode = 'rb'):
         """Ensures that the specified file contains the required text.
         """
         file_contents = self.read(file, mode)
-        contains = (string.find(file_contents, required) != -1)
+        contains = (file_contents.find(required) != -1)
         if not contains:
             print "File `%s' does not contain required string." % file
             print self.banner('Required string ')
         for lines in the output.
         """
         if find is None:
-            find = lambda o, l: string.find(o, l) != -1
+            find = lambda o, l: o.find(l) != -1
         missing = []
         for line in lines:
             if not find(output, line):
         for lines in the output.
         """
         if find is None:
-            find = lambda o, l: string.find(o, l) != -1
+            find = lambda o, l: o.find(l) != -1
         for line in lines:
             if find(output, line):
                 return
         pathname will be constructed by concatenating them.  Exits FAILED
         if any of the files does not exist.
         """
-        files = map(lambda x: is_List(x) and apply(os.path.join, x) or x, files)
-        missing = filter(lambda x: not os.path.exists(x), files)
+        files = [is_List(x) and os.path.join(*x) or x for x in files]
+        missing = [x for x in files if not os.path.exists(x)]
         if missing:
-            print "Missing files: `%s'" % string.join(missing, "', `")
+            print "Missing files: `%s'" % "', `".join(missing)
             self.fail_test(missing)
 
     def must_match(self, file, expect, mode = 'rb'):
         """Ensures that the specified file doesn't contain the banned text.
         """
         file_contents = self.read(file, mode)
-        contains = (string.find(file_contents, banned) != -1)
+        contains = (file_contents.find(banned) != -1)
         if contains:
             print "File `%s' contains banned string." % file
             print self.banner('Banned string ')
         for lines in the output.
         """
         if find is None:
-            find = lambda o, l: string.find(o, l) != -1
+            find = lambda o, l: o.find(l) != -1
         unexpected = []
         for line in lines:
             if find(output, line):
         which case the pathname will be constructed by concatenating them.
         Exits FAILED if any of the files exists.
         """
-        files = map(lambda x: is_List(x) and apply(os.path.join, x) or x, files)
-        existing = filter(os.path.exists, files)
+        files = [is_List(x) and os.path.join(*x) or x for x in files]
+        existing = list(filter(os.path.exists, files))
         if existing:
-            print "Unexpected files exist: `%s'" % string.join(existing, "', `")
+            print "Unexpected files exist: `%s'" % "', `".join(existing)
             self.fail_test(existing)
 
 
         them.  Exits FAILED if any of the files does not exist or is
         writable.
         """
-        files = map(lambda x: is_List(x) and apply(os.path.join, x) or x, files)
+        files = [is_List(x) and os.path.join(*x) or x for x in files]
         existing, missing = separate_files(files)
-        writable = filter(is_writable, existing)
+        writable = list(filter(is_writable, existing))
         if missing:
-            print "Missing files: `%s'" % string.join(missing, "', `")
+            print "Missing files: `%s'" % "', `".join(missing)
         if writable:
-            print "Writable files: `%s'" % string.join(writable, "', `")
+            print "Writable files: `%s'" % "', `".join(writable)
         self.fail_test(missing + writable)
 
     def _complete(self, actual_stdout, expected_stdout,
                 else:
                     arguments = options + " " + arguments
         try:
-            return apply(TestCmd.start,
-                         (self, program, interpreter, arguments, universal_newlines),
-                         kw)
+            return TestCmd.start(self, program, interpreter, arguments, universal_newlines,
+                         **kw)
         except KeyboardInterrupt:
             raise
         except Exception, e:
                         command.  A value of None means don't
                         test exit status.
         """
-        apply(TestCmd.finish, (self, popen,), kw)
+        TestCmd.finish(self, popen, **kw)
         match = kw.get('match', self.match)
         self._complete(self.stdout(), stdout,
                        self.stderr(), stderr, status, match)
             del kw['match']
         except KeyError:
             match = self.match
-        apply(TestCmd.run, [self], kw)
+        TestCmd.run(self, **kw)
         self._complete(self.stdout(), stdout,
                        self.stderr(), stderr, status, match)
 

QMTest/TestRuntest.py

 import os
 import os.path
 import re
-import string
 import shutil
 import sys
 
     pythonstring = _python_
 else:
     pythonstring = python
-pythonstring = string.replace(pythonstring, '\\', '\\\\')
+pythonstring = pythonstring.replace('\\', '\\\\')
 
 
 failing_test_template = """\
         appears in a normal workspace.
         """
         set_workpath_runtest = None
-        if not kw.has_key('program'):
+        if 'program' not in kw:
             kw['program'] = 'runtest.py'
             set_workpath_runtest = 1
-        if not kw.has_key('interpreter'):
+        if 'interpreter' not in kw:
             kw['interpreter'] = [python, '-tt']
-        if not kw.has_key('match'):
+        if 'match' not in kw:
             kw['match'] = match_exact
-        if not kw.has_key('workdir'):
+        if 'workdir' not in kw:
             kw['workdir'] = ''
 
         try:
             del kw['noqmtest']
 
         orig_cwd = os.getcwd()
-        apply(TestCommon.__init__, [self], kw)
+        TestCommon.__init__(self, **kw)
   
         if not noqmtest:
             qmtest = self.where_is('qmtest')
         dirs = [os.environ.get('SCONS_RUNTEST_DIR', orig_cwd)]
         
         spe = os.environ.get('SCONS_SOURCE_PATH_EXECUTABLE', orig_cwd)
-        for d in string.split(spe, os.pathsep):
+        for d in spe.split(os.pathsep):
             dirs.append(os.path.join(d, 'build'))
             dirs.append(d)
 

QMTest/TestSCons.py

 """
 
 # __COPYRIGHT__
+from __future__ import generators  ### KEEP FOR COMPATIBILITY FIXERS
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 import os
 import re
 import shutil
-import string
 import sys
 import time
 
     def zip(*lists):
         result = []
         for i in xrange(len(lists[0])):
-            result.append(tuple(map(lambda l, i=i: l[i], lists)))
+            result.append(tuple([l[i] for l in lists]))
         return result
     __builtin__.zip = zip
 
         stderr = p.stderr
 
     for l in stderr.readlines():
-        list = string.split(l)
+        list = l.split()
         if len(list) > 3 and list[:2] == ['gcc', 'version']:
             if list[2][:3] in ('4.1','4.2','4.3'):
                 libs = ['gfortranbegin']
     fortran_lib = gccFortranLibs()
 elif sys.platform == 'cygwin':
     fortran_lib = gccFortranLibs()
-elif string.find(sys.platform, 'irix') != -1:
+elif sys.platform.find('irix') != -1:
     fortran_lib = ['ftn']
 else:
     fortran_lib = gccFortranLibs()
 # re.escape escapes too much.
 def re_escape(str):
     for c in ['.', '[', ']', '(', ')', '*', '+', '?']:  # Not an exhaustive list.
-        str = string.replace(str, c, '\\' + c)
+        str = str.replace(c, '\\' + c)
     return str
 
 
     sys.version_info
 except AttributeError:
     # Pre-1.6 Python has no sys.version_info
-    version_string = string.split(sys.version)[0]
-    version_ints = map(int, string.split(version_string, '.'))
+    version_string = sys.version.split()[0]
+    version_ints = list(map(int, version_string.split('.')))
     sys.version_info = tuple(version_ints + ['final', 0])
 
 def python_version_string():
-    return string.split(sys.version)[0]
+    return sys.version.split()[0]
 
 def python_minor_version_string():
     return sys.version[:3]
             pass
         else:
             os.chdir(script_dir)
-        if not kw.has_key('program'):
+        if 'program' not in kw:
             kw['program'] = os.environ.get('SCONS')
             if not kw['program']:
                 if os.path.exists('scons'):
                     kw['program'] = 'scons.py'
             elif not os.path.isabs(kw['program']):
                 kw['program'] = os.path.join(self.orig_cwd, kw['program'])
-        if not kw.has_key('interpreter') and not os.environ.get('SCONS_EXEC'):
+        if 'interpreter' not in kw and not os.environ.get('SCONS_EXEC'):
             kw['interpreter'] = [python, '-tt']
-        if not kw.has_key('match'):
+        if 'match' not in kw:
             kw['match'] = match_exact
-        if not kw.has_key('workdir'):
+        if 'workdir' not in kw:
             kw['workdir'] = ''
 
         # Term causing test failures due to bogus readline init
             else:
                 sconsflags = []
             sconsflags = sconsflags + ['--warn=no-python-version']
-            os.environ['SCONSFLAGS'] = string.join(sconsflags)
+            os.environ['SCONSFLAGS'] = ' '.join(sconsflags)
 
-        apply(TestCommon.__init__, [self], kw)
+        TestCommon.__init__(self, **kw)
 
         import SCons.Node.FS
         if SCons.Node.FS.default_fs is None:
         if not ENV is None:
             kw['ENV'] = ENV
         try:
-            return apply(SCons.Environment.Environment, args, kw)
+            return SCons.Environment.Environment(*args, **kw)
         except (SCons.Errors.UserError, SCons.Errors.InternalError):
             return None
 
             return None
         result = env.WhereIs(prog)
         if norm and os.sep != '/':
-            result = string.replace(result, os.sep, '/')
+            result = result.replace(os.sep, '/')
         return result
 
     def detect_tool(self, tool, prog=None, ENV=None):
         # support the --warn=no-visual-c-missing warning.)
         sconsflags = sconsflags + [os.environ.get('TESTSCONS_SCONSFLAGS',
                                                   '--warn=no-visual-c-missing')]
-        os.environ['SCONSFLAGS'] = string.join(sconsflags)
+        os.environ['SCONSFLAGS'] = ' '.join(sconsflags)
         try:
-            result = apply(TestCommon.run, (self,)+args, kw)
+            result = TestCommon.run(self, *args, **kw)
         finally:
             sconsflags = save_sconsflags
         return result
 
     def up_to_date(self, options = None, arguments = None, read_str = "", **kw):
         s = ""
-        for arg in string.split(arguments):
+        for arg in arguments.split():
             s = s + "scons: `%s' is up to date.\n" % arg
             if options:
                 arguments = options + " " + arguments
         # up-to-date output is okay.
         kw['stdout'] = re.escape(stdout) + '.*'
         kw['match'] = self.match_re_dotall
-        apply(self.run, [], kw)
+        self.run(**kw)
 
     def not_up_to_date(self, options = None, arguments = None, **kw):
         """Asserts that none of the targets listed in arguments is
         This function is most useful in conjunction with the -n option.
         """
         s = ""
-        for arg in string.split(arguments):
+        for arg in arguments.split():
             s = s + "(?!scons: `%s' is up to date.)" % re.escape(arg)
             if options:
                 arguments = options + " " + arguments
         s = '('+s+'[^\n]*\n)*'
         kw['arguments'] = arguments
         stdout = re.escape(self.wrap_stdout(build_str='ARGUMENTSGOHERE'))
-        kw['stdout'] = string.replace(stdout, 'ARGUMENTSGOHERE', s)
+        kw['stdout'] = stdout.replace('ARGUMENTSGOHERE', s)
         kw['match'] = self.match_re_dotall
-        apply(self.run, [], kw)
+        self.run(**kw)
 
     def option_not_yet_implemented(self, option, arguments=None, **kw):
         """
                 kw['arguments'] = option + ' ' + arguments
         # TODO(1.5)
         #return self.run(**kw)
-        return apply(self.run, (), kw)
+        return self.run(**kw)
 
     def diff_substr(self, expect, actual, prelen=20, postlen=40):
         i = 0
         places, abstracting out the version difference.
         """
         exec 'import traceback; x = traceback.format_stack()[-1]'
-        x = string.lstrip(x)
-        x = string.replace(x, '<string>', file)
-        x = string.replace(x, 'line 1,', 'line %s,' % line)
+        x = x.lstrip()
+        x = x.replace('<string>', file)
+        x = x.replace('line 1,', 'line %s,' % line)
         return x
 
     def normalize_pdf(self, s):
             end_marker = 'endstream\nendobj'
 
             encoded = []
-            b = string.find(s, begin_marker, 0)
+            b = s.find(begin_marker, 0)
             while b != -1:
                 b = b + len(begin_marker)
-                e = string.find(s, end_marker, b)
+                e = s.find(end_marker, b)
                 encoded.append((b, e))
-                b = string.find(s, begin_marker, e + len(end_marker))
+                b = s.find(begin_marker, e + len(end_marker))
 
             x = 0
             r = []
                 r.append(d)
                 x = e
             r.append(s[x:])
-            s = string.join(r, '')
+            s = ''.join(r)
 
         return s
 
             ]
             java_path = self.paths(patterns) + [env['ENV']['PATH']]
 
-        env['ENV']['PATH'] = string.join(java_path, os.pathsep)
+        env['ENV']['PATH'] = os.pathsep.join(java_path)
         return env['ENV']
 
     def java_where_includes(self,version=None):
                  stderr=None,
                  status=None)
         if version:
-            if string.find(self.stderr(), 'javac %s' % version) == -1:
+            if self.stderr().find('javac %s' % version) == -1:
                 fmt = "Could not find javac for Java version %s, skipping test(s).\n"
                 self.skip_test(fmt % version)
         else:
         self.write([dir, 'bin', 'mymoc.py'], """\
 import getopt
 import sys
-import string
 import re
 # -w and -z are fake options used in test/QT/QTFLAGS.py
 cmd_opts, args = getopt.getopt(sys.argv[1:], 'io:wz', [])
 output.write("/* mymoc.py%s */\\n" % opt_string)
 for a in args:
     contents = open(a, 'rb').read()
-    a = string.replace(a, '\\\\', '\\\\\\\\')
+    a = a.replace('\\\\', '\\\\\\\\')
     subst = r'{ my_qt_symbol( "' + a + '\\\\n" ); }'
     if impl:
         contents = re.sub( r'#include.*', '', contents )
-    output.write(string.replace(contents, 'Q_OBJECT', subst))
+    output.write(contents.replace('Q_OBJECT', subst))
 output.close()
 sys.exit(0)
 """)
 import os.path
 import re
 import sys
-import string
 output_arg = 0
 impl_arg = 0
 impl = None
 
     def Qt_create_SConstruct(self, place):
         if type(place) is type([]):
-            place = apply(test.workpath, place)
+            place = test.workpath(*place)
         self.write(place, """\
 if ARGUMENTS.get('noqtdir', 0): QTDIR=None
 else: QTDIR=r'%s'
             lastEnd = 0
             logfile = self.read(self.workpath(logfile))
             if (doCheckLog and
-                string.find( logfile, "scons: warning: The stored build "
+                logfile.find( "scons: warning: The stored build "
                              "information has an unexpected class." ) >= 0):
                 self.fail_test()
             sconf_dir = sconf_dir
 print py_ver
 """)
 
-        return [python] + string.split(string.strip(self.stdout()), '\n')
+        return [python] + self.stdout().strip().split('\n')
 
     def start(self, *args, **kw):
         """
         use standard input without forcing every .start() call in the
         individual tests to do so explicitly.
         """
-        if not kw.has_key('stdin'):
+        if 'stdin' not in kw:
             kw['stdin'] = True
-        return apply(TestCommon.start, (self,) + args, kw)
+        return TestCommon.start(self, *args, **kw)
 
     def wait_for(self, fname, timeout=10.0, popen=None):
         """
 
         self.calibrate = os.environ.get('TIMESCONS_CALIBRATE', '0') != '0'
 
-        if not kw.has_key('verbose') and not self.calibrate:
+        if 'verbose' not in kw and not self.calibrate:
             kw['verbose'] = True
 
         # TODO(1.5)
         #TestSCons.__init__(self, *args, **kw)
-        apply(TestSCons.__init__, (self,)+args, kw)
+        TestSCons.__init__(self, *args, **kw)
 
         # TODO(sgk):    better way to get the script dir than sys.argv[0]
         test_dir = os.path.dirname(sys.argv[0])
         The elapsed time to execute each build is printed after
         it has finished.
         """
-        if not kw.has_key('options') and self.variables:
+        if 'options' not in kw and self.variables:
             options = []
             for variable, value in self.variables.items():
                 options.append('%s=%s' % (variable, value))
         if self.calibrate:
             # TODO(1.5)
             #self.calibration(*args, **kw)
-            apply(self.calibration, args, kw)
+            self.calibration(*args, **kw)
         else:
             self.uptime()
             # TODO(1.5)
             #self.startup(*args, **kw)
             #self.full(*args, **kw)
             #self.null(*args, **kw)
-            apply(self.startup, args, kw)
-            apply(self.full, args, kw)
-            apply(self.null, args, kw)
+            self.startup(*args, **kw)
+            self.full(*args, **kw)
+            self.null(*args, **kw)
 
     def trace(self, graph, name, value, units, sort=None):
         fmt = "TRACE: graph=%s name=%s value=%s units=%s"
         for name, args in stats.items():
             # TODO(1.5)
             #self.trace(name, trace, *args)
-            apply(self.trace, (name, trace), args)
+            self.trace(name, trace, **args)
 
     def uptime(self):
         try:
         kw['status'] = None
         # TODO(1.5)
         #self.run(*args, **kw)
-        apply(self.run, args, kw)
+        self.run(*args, **kw)
         sys.stdout.write(self.stdout())
         stats = self.collect_stats(self.stdout())
         # Delete the time-commands, since no commands are ever
         """
         # TODO(1.5)
         #self.run(*args, **kw)
-        apply(self.run, args, kw)
+        self.run(*args, **kw)
         sys.stdout.write(self.stdout())
         stats = self.collect_stats(self.stdout())
         self.report_traces('full', stats)
         #self.trace('full-memory', 'initial', **stats['memory-initial'])
         #self.trace('full-memory', 'prebuild', **stats['memory-prebuild'])
         #self.trace('full-memory', 'final', **stats['memory-final'])
-        apply(self.trace, ('full-memory', 'initial'), stats['memory-initial'])
-        apply(self.trace, ('full-memory', 'prebuild'), stats['memory-prebuild'])
-        apply(self.trace, ('full-memory', 'final'), stats['memory-final'])
+        self.trace('full-memory', 'initial', **stats['memory-initial'])
+        self.trace('full-memory', 'prebuild', **stats['memory-prebuild'])
+        self.trace('full-memory', 'final', **stats['memory-final'])
 
     def calibration(self, *args, **kw):
         """
         """
         # TODO(1.5)
         #self.run(*args, **kw)
-        apply(self.run, args, kw)
+        self.run(*args, **kw)
         if self.variables:
             for variable, value in self.variables.items():
                 sys.stdout.write('VARIABLE: %s=%s\n' % (variable, value))
         #self.up_to_date(arguments='.', **kw)
         kw = kw.copy()
         kw['arguments'] = '.'
-        apply(self.up_to_date, (), kw)
+        self.up_to_date(**kw)
         sys.stdout.write(self.stdout())
         stats = self.collect_stats(self.stdout())
         # time-commands should always be 0.0 on a null build, because
         #self.trace('null-memory', 'initial', **stats['memory-initial'])
         #self.trace('null-memory', 'prebuild', **stats['memory-prebuild'])
         #self.trace('null-memory', 'final', **stats['memory-final'])
-        apply(self.trace, ('null-memory', 'initial'), stats['memory-initial'])
-        apply(self.trace, ('null-memory', 'prebuild'), stats['memory-prebuild'])
-        apply(self.trace, ('null-memory', 'final'), stats['memory-final'])
+        self.trace('null-memory', 'initial', **stats['memory-initial'])
+        self.trace('null-memory', 'prebuild', **stats['memory-prebuild'])
+        self.trace('null-memory', 'final', **stats['memory-final'])
 
     def elapsed_time(self):
         """
         try:
             # TODO(1.5)
             #result = TestSCons.run(self, *args, **kw)
-            result = apply(TestSCons.run, (self,)+args, kw)
+            result = TestSCons.run(self, *args, **kw)
         finally:
             self.endTime = time.time()
         return result
             #dirs = [ d for d in dirs if not d.startswith('TimeSCons-') ]
             #files = [ f for f in files if not f.startswith('TimeSCons-') ]
             not_timescons_entries = lambda s: not s.startswith('TimeSCons-')
-            dirs = filter(not_timescons_entries, dirs)
-            files = filter(not_timescons_entries, files)
+            dirs = list(filter(not_timescons_entries, dirs))
+            files = list(filter(not_timescons_entries, files))
             for dirname in dirs:
                 source = os.path.join(root, dirname)
                 destination = source.replace(source_dir, dest_dir)

QMTest/TestSConsMSVS.py

 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 import os
-import string
 import sys
 
 from TestSCons import *
         replace = 'sys.path = [ %s, join(sys' % enginepath
 
         contents = self.read(fname)
-        contents = string.replace(contents, orig, replace)
+        contents = contents.replace(orig, replace)
         self.write(fname, contents)
 
     def msvs_substitute(self, input, msvs_ver,
         if project_guid is None:
             project_guid = "{E5466E26-0003-F18B-8F8A-BCD76C86388D}"
 
-        if os.environ.has_key('SCONS_LIB_DIR'):
+        if 'SCONS_LIB_DIR' in os.environ:
             exec_script_main = "from os.path import join; import sys; sys.path = [ r'%s' ] + sys.path; import SCons.Script; SCons.Script.main()" % os.environ['SCONS_LIB_DIR']
         else:
             exec_script_main = "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-%s'), join(sys.prefix, 'scons-%s'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()" % (self.scons_version, self.scons_version)
-        exec_script_main_xml = string.replace(exec_script_main, "'", "&apos;")
+        exec_script_main_xml = exec_script_main.replace("'", "&apos;")
 
-        result = string.replace(input, r'<WORKPATH>', workpath)
-        result = string.replace(result, r'<PYTHON>', python)
-        result = string.replace(result, r'<SCONSCRIPT>', sconscript)
-        result = string.replace(result, r'<SCONS_SCRIPT_MAIN>', exec_script_main)
-        result = string.replace(result, r'<SCONS_SCRIPT_MAIN_XML>', exec_script_main_xml)
-        result = string.replace(result, r'<PROJECT_GUID>', project_guid)
+        result = input.replace(r'<WORKPATH>', workpath)
+        result = result.replace(r'<PYTHON>', python)
+        result = result.replace(r'<SCONSCRIPT>', sconscript)
+        result = result.replace(r'<SCONS_SCRIPT_MAIN>', exec_script_main)
+        result = result.replace(r'<SCONS_SCRIPT_MAIN_XML>', exec_script_main_xml)
+        result = result.replace(r'<PROJECT_GUID>', project_guid)
         return result
 
     def get_msvs_executable(self, version):
         else:
             sconsflags = []
         sconsflags = sconsflags + ['--warn=no-deprecated']
-        os.environ['SCONSFLAGS'] = string.join(sconsflags)
+        os.environ['SCONSFLAGS'] = ' '.join(sconsflags)
         try:
-            result = apply(TestSCons.run, (self,)+args, kw)
+            result = TestSCons.run(self, *args, **kw)
         finally:
             os.environ['SCONSFLAGS'] = save_sconsflags or ''
         return result

QMTest/TestSCons_time.py

 
 import os
 import os.path
-import string
 import sys
 
 from TestCommon import *
             pass
         else:
             os.chdir(script_dir)
-        if not kw.has_key('program'):
+        if 'program' not in kw:
             p = os.environ.get('SCONS_TIME')
             if not p:
                 p = 'scons-time'
                     p = 'scons-time.py'
             kw['program'] = p
 
-        if not kw.has_key('interpreter'):
+        if 'interpreter' not in kw:
             kw['interpreter'] = [python, '-tt']
 
-        if not kw.has_key('match'):
+        if 'match' not in kw:
             kw['match'] = match_exact
 
-        if not kw.has_key('workdir'):
+        if 'workdir' not in kw:
             kw['workdir'] = ''
 
-        apply(TestCommon.__init__, [self], kw)
+        TestCommon.__init__(self, **kw)
 
         # Now that the testing object has been set up, check if we should
         # skip the test due to the Python version.  We need to be able to
         try:
             import __future__
         except ImportError:
-            version = string.split(sys.version)[0]
+            version = sys.version.split()[0]
             msg = 'scons-time does not work on Python version %s\n' % version
             self.skip_test(msg)
 
         try:
             eval('[x for x in [1, 2]]')
         except SyntaxError:
-            version = string.split(sys.version)[0]
+            version = sys.version.split()[0]
             msg = 'scons-time does not work on Python version %s\n' % version
             self.skip_test(msg)
 
             tempdir = realpath(tempdir)
 
         args = (tempdir, 'scons-time-',) + args
-        x = apply(os.path.join, args)
+        x = os.path.join(*args)
         x = re.escape(x)
-        x = string.replace(x, 'time\\-', 'time\\-[^%s]*' % sep)
+        x = x.replace('time\\-', 'time\\-[^%s]*' % sep)
         return x
 
     def write_fake_aegis_py(self, name):

QMTest/TestSConsign.py

 
 import os
 import os.path
-import string
 import sys
 
 from TestSCons import *
             os.chdir(script_dir)
         self.script_dir = os.getcwd()
 
-        apply(TestSCons.__init__, (self,)+args, kw)
+        TestSCons.__init__(self, *args, **kw)
 
         self.my_kw = {
             'interpreter' : python,     # imported from TestSCons
         }
 
-        if not kw.has_key('program'):
+        if 'program' not in kw:
             kw['program'] = os.environ.get('SCONS')
             if not kw['program']:
                 if os.path.exists('scons'):
 
     def run_sconsign(self, *args, **kw):
         kw.update(self.my_kw)
-        return apply(self.run, args, kw)
+        return self.run(*args, **kw)
 
 # Local Variables:
 # tab-width:4

QMTest/scons_tdb.py

 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #
 
-__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-
 """
 QMTest classes to support SCons' testing and Aegis-inspired workflow.
 
 Thanks to Stefan Seefeld for the initial code.
 """
+from __future__ import generators  ### KEEP FOR COMPATIBILITY FIXERS
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 ########################################################################
 # Imports
         # Do not record computed fields.
         if field.IsComputed():
             continue
-        if e.__dict__.has_key(name):
+        if name in e.__dict__:
             explicit_arguments[name] = e.__dict__[name]
 
     return explicit_arguments
 
 def get_sys_values():
     sys_attributes.sort()
-    result = map(lambda k: (k, getattr(sys, k, _null)), sys_attributes)
-    result = filter(lambda t: not t[1] is _null, result)
-    result = map(lambda t: t[0] + '=' + repr(t[1]), result)
-    return string.join(result, '\n ')
+    result = [(k, getattr(sys, k, _null)) for k in sys_attributes]
+    result = [t for t in result if not t[1] is _null]
+    result = [t[0] + '=' + repr(t[1]) for t in result]
+    return '\n '.join(result)
 
 module_attributes = [
     '__version__',
 
 def get_module_info(module):
     module_attributes.sort()
-    result = map(lambda k: (k, getattr(module, k, _null)), module_attributes)
-    result = filter(lambda t: not t[1] is _null, result)
-    result = map(lambda t: t[0] + '=' + repr(t[1]), result)
-    return string.join(result, '\n ')
+    result = [(k, getattr(module, k, _null)) for k in module_attributes]
+    result = [t for t in result if not t[1] is _null]
+    result = [t[0] + '=' + repr(t[1]) for t in result]
+    return '\n '.join(result)
 
 environ_keys = [
    'PATH',
 
 def get_environment():
     environ_keys.sort()
-    result = map(lambda k: (k, os.environ.get(k, _null)), environ_keys)
-    result = filter(lambda t: not t[1] is _null, result)
-    result = map(lambda t: t[0] + '-' + t[1], result)
-    return string.join(result, '\n ')
+    result = [(k, os.environ.get(k, _null)) for k in environ_keys]
+    result = [t for t in result if not t[1] is _null]
+    result = [t[0] + '-' + t[1] for t in result]
+    return '\n '.join(result)
 
 class SConsXMLResultStream(XMLResultStream):
     def __init__(self, *args, **kw):
         file_names.sort()
         for file_name in file_names:
             exit_status = self._outcomes[file_name]
-            file_name = string.replace(file_name, '\\', '/')
+            file_name = file_name.replace('\\', '/')
             self.file.write('    { file_name = "%s";\n' % file_name)
             self.file.write('      exit_status = %s; },\n' % exit_status)
         self.file.write('];\n')

QMTest/unittest.py

 AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 """
+from __future__ import generators  ### KEEP FOR COMPATIBILITY FIXERS
 
 __author__ = "Steve Purcell (stephen_purcell@yahoo.com)"
 __version__ = "$ Revision: 1.23 $"[11:-2]
 import time
 import sys
 import traceback
-import string
 import os
 
 ##############################################################################
 # A platform-specific concession to help the code work for JPython users
 ##############################################################################
 
-plat = string.lower(sys.platform)
-_isJPython = string.find(plat, 'java') >= 0 or string.find(plat, 'jdk') >= 0
+plat = sys.platform.lower()
+_isJPython = plat.find('java') >= 0 or plat.find('jdk') >= 0
 del plat
 
 
         the specified test method's docstring.
         """
         doc = self.__testMethod.__doc__
-        return doc and string.strip(string.split(doc, "\n")[0]) or None
+        return doc and doc.split("\n")[0].strip() or None
 
     def id(self):
         return "%s.%s" % (self.__class__, self.__testMethod.__name__)
 
     def failIf(self, expr, msg=None):
         "Fail the test if the expression is true."
-        apply(self.assert_,(not expr,msg))
+        self.assert_(not expr,msg)
 
     def assertRaises(self, excClass, callableObj, *args, **kwargs):
         """Assert that an exception of class excClass is thrown
            unexpected exception.
         """
         try:
-            apply(callableObj, args, kwargs)
+            callableObj(*args, **kwargs)
         except excClass:
             return
         else:
     def shortDescription(self):
         if self.__description is not None: return self.__description
         doc = self.__testFunc.__doc__
-        return doc and string.strip(string.split(doc, "\n")[0]) or None
+        return doc and doc.split("\n")[0].strip() or None
 
 
 
        and its base classes that start with the given prefix. This is used
        by makeSuite().
     """
-    testFnNames = filter(lambda n,p=prefix: n[:len(p)] == p,
-                         dir(testCaseClass))
+    testFnNames = [n for n in dir(testCaseClass) if n[:len(prefix)] == prefix]
     for baseclass in testCaseClass.__bases__:
         testFnNames = testFnNames + \
                       getTestCaseNames(baseclass, prefix, sortUsing=None)
        prefix. The cases are sorted by their function names
        using the supplied comparison function, which defaults to 'cmp'.
     """
-    cases = map(testCaseClass,
-                getTestCaseNames(testCaseClass, prefix, sortUsing))
+    cases = list(map(testCaseClass,
+                getTestCaseNames(testCaseClass, prefix, sortUsing)))
     return TestSuite(cases)
 
 
         -- returns result of calling makeSuite(ListTestCase, prefix="check")
     """
           
-    spec = string.split(name, ':')
+    spec = name.split(':')
     if len(spec) > 2: raise ValueError, "illegal test name: %s" % name
     if len(spec) == 1:
         testName = spec[0]
         caseName = None
     else:
         testName, caseName = spec
-    parts = string.split(testName, '.')
+    parts = testName.split('.')
     if module is None:
         if len(parts) < 2:
             raise ValueError, "incomplete test name: %s" % name
-        constructor = __import__(string.join(parts[:-1],'.'))
+        constructor = __import__('.'.join(parts[:-1]))
         parts = parts[1:]
     else:
         constructor = module
         return getattr(self.stream,attr)
 
     def writeln(self, *args):
-        if args: apply(self.write, args)
+        if args: self.write(*args)
         self.write(self.linesep)
 
  
                                 (len(errors), errFlavour))
         i = 1
         for test,error in errors:
-            errString = string.join(apply(traceback.format_exception,error),"")
+            errString = "".join(traceback.format_exception(*error))
             self.stream.writeln("%i) %s" % (i, test))
             self.stream.writeln(errString)
             i = i + 1
             self.stream.writeln(separator1)
         self.stream.writeln("\t%s" % flavour)
         self.stream.writeln(separator2)
-        for line in apply(traceback.format_exception, err):
-            for l in string.split(line,"\n")[:-1]:
+        for line in traceback.format_exception(*err):
+            for l in line.split("\n")[:-1]:
                 self.stream.writeln("\t%s" % l)
         self.stream.writeln(separator1)
 
         self.stream.writeln()
         if not result.wasSuccessful():
             self.stream.write("FAILED (")
-            failed, errored = map(len, (result.failures, result.errors))
+            failed = len(result.failures)
             if failed:
                 self.stream.write("failures=%d" % failed)
+            errored = len(result.errors)
             if errored:
                 if failed: self.stream.write(", ")
                 self.stream.write("errors=%d" % errored)
                  argv=None, testRunner=None):
         if type(module) == type(''):
             self.module = __import__(module)
-            for part in string.split(module,'.')[1:]:
+            for part in module.split('.')[1:]:
                 self.module = getattr(self.module, part)
         else:
             self.module = module
 #
 # See the README file for an overview of how SCons is built and tested.
 #
+from __future__ import generators  ### KEEP FOR COMPATIBILITY FIXERS
 
 # When this gets changed, you must also change the copyright_years string
 # in QMTest/TestSCons.py so the test scripts look for the right string.
 import os.path
 import re
 import stat
-import string
 import sys
 import tempfile
 
     exts = ['']
     if platform == "win32":
         exts += ['.exe']
-    for dir in string.split(os.environ['PATH'], os.pathsep):
+    for dir in os.environ['PATH'].split(os.pathsep):
         f = os.path.join(dir, file)
         for ext in exts:
             f_ext = f + ext
 build_system = ARGUMENTS.get('BUILD_SYSTEM')
 if not build_system:
     import socket
-    build_system = string.split(socket.gethostname(), '.')[0]
+    build_system = socket.gethostname().split('.')[0]
 
 version = ARGUMENTS.get('VERSION', '')
 if not version:
             revision = b.group(1) + ':' + revision
         def generate_build_id(revision):
             result = revision
-            if filter(lambda l: l[0] in 'AMR!', hg_status_lines):
+            if [l for l in hg_status_lines if l[0] in 'AMR!']:
                 result = result + '[MODIFIED]'
             return result
 
         revision = m.group(1)
         def generate_build_id(revision):
             result = 'r' + revision
-            if filter(lambda l: l[0] in 'ACDMR', svn_status_lines):
+            if [l for l in svn_status_lines if l[0] in 'ACDMR']:
                 result = result + '[MODIFIED]'
             return result
 
 
 ENV = { 'PATH' : os.environ['PATH'] }
 for key in ['LOGNAME', 'PYTHONPATH', 'LD_LIBRARY_PATH']:
-    if os.environ.has_key(key):
+    if key in os.environ:
         ENV[key] = os.environ[key]
 
 build_dir = ARGUMENTS.get('BUILDDIR', 'build')
     # Note:  We construct the __*__ substitution strings here
     # so that they don't get replaced when this file gets
     # copied into the tree for packaging.
-    contents = string.replace(contents, '__BUILD'     + '__', env['BUILD'])
-    contents = string.replace(contents, '__BUILDSYS'  + '__', env['BUILDSYS'])
-    contents = string.replace(contents, '__COPYRIGHT' + '__', env['COPYRIGHT'])
-    contents = string.replace(contents, '__DATE'      + '__', env['DATE'])
-    contents = string.replace(contents, '__DEVELOPER' + '__', env['DEVELOPER'])
-    contents = string.replace(contents, '__FILE'      + '__', str(source[0]))
-    contents = string.replace(contents, '__MONTH_YEAR'+ '__', env['MONTH_YEAR'])
-    contents = string.replace(contents, '__REVISION'  + '__', env['REVISION'])
-    contents = string.replace(contents, '__VERSION'   + '__', env['VERSION'])
-    contents = string.replace(contents, '__NULL'      + '__', '')
+    contents = contents.replace('__BUILD'     + '__', env['BUILD'])
+    contents = contents.replace('__BUILDSYS'  + '__', env['BUILDSYS'])
+    contents = contents.replace('__COPYRIGHT' + '__', env['COPYRIGHT'])
+    contents = contents.replace('__DATE'      + '__', env['DATE'])
+    contents = contents.replace('__DEVELOPER' + '__', env['DEVELOPER'])
+    contents = contents.replace('__FILE'      + '__', str(source[0]))
+    contents = contents.replace('__MONTH_YEAR'+ '__', env['MONTH_YEAR'])
+    contents = contents.replace('__REVISION'  + '__', env['REVISION'])
+    contents = contents.replace('__VERSION'   + '__', env['VERSION'])
+    contents = contents.replace('__NULL'      + '__', '')
     open(t, 'wb').write(contents)
     os.chmod(t, os.stat(s)[0])
 
     pkg_version = "%s-%s" % (pkg, version)
 
     src = 'src'
-    if p.has_key('src_subdir'):
+    if 'src_subdir' in p:
         src = os.path.join(src, p['src_subdir'])
 
     build = os.path.join(build_dir, pkg)
     # destination files.
     #
     manifest_in = File(os.path.join(src, 'MANIFEST.in')).rstr()
-    src_files = map(lambda x: x[:-1],
-                    open(manifest_in).readlines())
+    src_files = [x[:-1] for x in open(manifest_in).readlines()]
     raw_files = src_files[:]
     dst_files = src_files[:]
     rpm_files = []
 
     MANIFEST_in_list = []
 
-    if p.has_key('subpkgs'):
+    if 'subpkgs' in p:
         #
         # This package includes some sub-packages.  Read up their
         # MANIFEST.in files, and add them to our source and destination
             isubdir = p['subinst_dirs'][sp['pkg']]
             MANIFEST_in = File(os.path.join(src, ssubdir, 'MANIFEST.in')).rstr()
             MANIFEST_in_list.append(MANIFEST_in)
-            files = map(lambda x: x[:-1], open(MANIFEST_in).readlines())
+            files = [x[:-1] for x in open(MANIFEST_in).readlines()]
             raw_files.extend(files)
-            src_files.extend(map(lambda x, s=ssubdir: os.path.join(s, x), files))
+            src_files.extend([os.path.join(subdir, x) for x in files])
             for f in files:
                 r = os.path.join(sp['rpm_dir'], f)
                 rpm_files.append(r)
             for f in sp.get('extra_rpm_files', []):
                 r = os.path.join(sp['rpm_dir'], f)
                 rpm_files.append(r)
-            files = map(lambda x, i=isubdir: os.path.join(i, x), files)
+            files = [os.path.join(isubdir, x) for x in files]
             dst_files.extend(files)
             for k, f in sp['filemap'].items():
                 if f:
     #
     # Now go through and arrange to create whatever packages we can.
     #
-    build_src_files = map(lambda x, b=build: os.path.join(b, x), src_files)
-    apply(Local, build_src_files, {})
+    build_src_files = [os.path.join(build, x) for x in src_files]
+    Local(*build_src_files)
 
     distutils_formats = []
 
         # but that gives heartburn to Cygwin's tar, so work around it
         # with separate zcat-tar-rm commands.
         #
-        unpack_tar_gz_files = map(lambda x, u=unpack_tar_gz_dir, pv=pkg_version:
-                                         os.path.join(u, pv, x),
-                                  src_files)
+        unpack_tar_gz_files = [os.path.join(unpack_tar_gz_dir, pkg_version, x)
+                               for x in src_files]
         env.Command(unpack_tar_gz_files, dist_tar_gz, [
                     Delete(os.path.join(unpack_tar_gz_dir, pkg_version)),
                     "$ZCAT $SOURCES > .temp",