summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--QMTest/TestCmd.py5
-rw-r--r--QMTest/TestSCons.py8
-rw-r--r--QMTest/unittest.py5
-rw-r--r--src/engine/SCons/Builder.py2
-rw-r--r--src/engine/SCons/EnvironmentTests.py20
-rw-r--r--src/engine/SCons/Node/FS.py3
-rw-r--r--src/engine/SCons/Node/FSTests.py2
-rw-r--r--src/engine/SCons/Script/Main.py2
-rw-r--r--src/engine/SCons/Taskmaster.py3
-rw-r--r--src/engine/SCons/Variables/__init__.py2
-rw-r--r--src/engine/SCons/compat/__init__.py47
-rw-r--r--src/engine/SCons/compat/_scons_builtins.py4
-rw-r--r--src/engine/SCons/cpp.py2
-rw-r--r--test/NodeOps.py2
-rw-r--r--test/exitfns.py4
15 files changed, 60 insertions, 51 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py
index 6f53892..1568b0d 100644
--- a/QMTest/TestCmd.py
+++ b/QMTest/TestCmd.py
@@ -581,9 +581,8 @@ except ImportError:
# The subprocess module doesn't exist in this version of Python,
# so we're going to cobble up something that looks just enough
# like its API for our purposes below.
- import new
-
- subprocess = new.module('subprocess')
+ from types import ModuleType
+ class subprocess(ModuleType): pass
subprocess.PIPE = 'PIPE'
subprocess.STDOUT = 'STDOUT'
diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py
index d61c008..a4e9c86 100644
--- a/QMTest/TestSCons.py
+++ b/QMTest/TestSCons.py
@@ -1259,12 +1259,8 @@ class TimeSCons(TestSCons):
for root, dirs, files in os.walk(source_dir):
if '.svn' in dirs:
dirs.remove('.svn')
- # TODO(1.5)
- #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 = list(filter(not_timescons_entries, dirs))
- files = list(filter(not_timescons_entries, files))
+ dirs = [ d for d in dirs if not d.startswith('TimeSCons-') ]
+ files = [ f for f in files if not f.startswith('TimeSCons-') ]
for dirname in dirs:
source = os.path.join(root, dirname)
destination = source.replace(source_dir, dest_dir)
diff --git a/QMTest/unittest.py b/QMTest/unittest.py
index 1d87c15..4a4433e 100644
--- a/QMTest/unittest.py
+++ b/QMTest/unittest.py
@@ -344,7 +344,10 @@ def getTestCaseNames(testCaseClass, prefix, sortUsing=cmp):
testFnNames = testFnNames + \
getTestCaseNames(baseclass, prefix, sortUsing=None)
if sortUsing:
- testFnNames.sort(sortUsing)
+ # sortUsing is only either 'None' or 'cmp' so don't bother with arg
+ # which is not supported in Py3k.
+ #testFnNames.sort(sortUsing)
+ testFnNames.sort()
return testFnNames
diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py
index bbf503c..1d20a4f 100644
--- a/src/engine/SCons/Builder.py
+++ b/src/engine/SCons/Builder.py
@@ -122,7 +122,7 @@ def match_splitext(path, suffixes = []):
if suffixes:
matchsuf = [S for S in suffixes if path[-len(S):] == S]
if matchsuf:
- suf = max(list(map(None, list(map(len, matchsuf)), matchsuf)))[1]
+ suf = max([(len(_f),_f) for _f in matchsuf])[1]
return [path[:-len(suf)], path[-len(suf):]]
return SCons.Util.splitext(path)
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 9f0e167..99b3d93 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -25,13 +25,13 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import SCons.compat
-import collections
import copy
import io
import os
import sys
import TestCmd
import unittest
+from collections import UserDict as UD, UserList as UL
from SCons.Environment import *
import SCons.Warnings
@@ -126,15 +126,15 @@ class Scanner:
-class CLVar(collections.UserList):
+class CLVar(UL):
def __init__(self, seq):
if isinstance(seq, str):
seq = seq.split()
- collections.UserList.__init__(self, seq)
+ UL.__init__(self, seq)
def __add__(self, other):
- return collections.UserList.__add__(self, CLVar(other))
+ return UL.__add__(self, CLVar(other))
def __radd__(self, other):
- return collections.UserList.__radd__(self, CLVar(other))
+ return UL.__radd__(self, CLVar(other))
def __coerce__(self, other):
return (self, CLVar(other))
@@ -1479,11 +1479,6 @@ def exists(env):
b2 = Environment()['BUILDERS']
assert b1 == b2, diff_dict(b1, b2)
- import UserDict
- UD = collections.UserDict
- import UserList
- UL = collections.UserList
-
cases = [
'a1', 'A1', 'a1A1',
'a2', ['A2'], ['a2', 'A2'],
@@ -2151,11 +2146,6 @@ f5: \
def test_Prepend(self):
"""Test prepending to construction variables in an Environment
"""
- import UserDict
- UD = collections.UserDict
- import UserList
- UL = collections.UserList
-
cases = [
'a1', 'A1', 'A1a1',
'a2', ['A2'], ['A2', 'a2'],
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 6dd5b0b..c8b900f 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -1960,8 +1960,7 @@ class Dir(Base):
if strings:
r = [os.path.join(str(dir), x) for x in r]
result.extend(r)
- result.sort(lambda a, b: cmp(str(a), str(b)))
- return result
+ return sorted(result, key=lambda a: str(a))
def _glob1(self, pattern, ondisk=True, source=False, strings=False):
"""
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index 8ced548..339d124 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -2251,7 +2251,7 @@ class GlobTestCase(_tempdirTestCase):
for input, string_expect, node_expect in cases:
r = self.fs.Glob(input, **kwargs)
if node_expect:
- r.sort(lambda a,b: cmp(a.path, b.path))
+ r = sorted(r, key=lambda a: a.path)
result = []
for n in node_expect:
if isinstance(n, str):
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py
index 96fc4b7..7a8f698 100644
--- a/src/engine/SCons/Script/Main.py
+++ b/src/engine/SCons/Script/Main.py
@@ -528,7 +528,7 @@ class MemStats(Stats):
self.stats.append(SCons.Debug.memory())
def do_print(self):
fmt = 'Memory %-32s %12d\n'
- for label, stats in map(None, self.labels, self.stats):
+ for label, stats in zip(self.labels, self.stats):
self.outfp.write(fmt % (label, stats))
memory_stats = MemStats()
diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py
index f60b2e2..e55757a 100644
--- a/src/engine/SCons/Taskmaster.py
+++ b/src/engine/SCons/Taskmaster.py
@@ -107,8 +107,7 @@ fmt = "%(considered)3d "\
"%(build)3d "
def dump_stats():
- StatsNodes.sort(lambda a, b: cmp(str(a), str(b)))
- for n in StatsNodes:
+ for n in sorted(StatsNodes, key=lambda a: str(a)):
print (fmt % n.stats.__dict__) + str(n)
diff --git a/src/engine/SCons/Variables/__init__.py b/src/engine/SCons/Variables/__init__.py
index 171c098..750d4b3 100644
--- a/src/engine/SCons/Variables/__init__.py
+++ b/src/engine/SCons/Variables/__init__.py
@@ -284,7 +284,7 @@ class Variables:
"""
if sort:
- options = sorted(self.options, cmp=lambda x,y: sort(x.key,y.key))
+ options = sorted(self.options, key=lambda x: x.key)
else:
options = self.options
diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py
index a68ef72..62c6467 100644
--- a/src/engine/SCons/compat/__init__.py
+++ b/src/engine/SCons/compat/__init__.py
@@ -227,18 +227,23 @@ except AttributeError:
os.path.lexists = lexists
-try:
- # Use the "imp" module to protect the import from fixers.
- import imp
- _cPickle = imp.load_module('cPickle', *imp.find_module('cPickle'))
-except ImportError, e:
- # The "cPickle" module has already been eliminated in favor of
- # having "import pickle" import the fast version when available.
- pass
-else:
- import sys
- sys.modules['pickle'] = _cPickle
- del _cPickle
+# When we're using the '-3' option during regression tests, importing
+# cPickle gives a warning no matter how it's done, so always use the
+# real profile module, whether it's fast or not.
+if os.environ.get('SCONS_HORRIBLE_REGRESSION_TEST_HACK') is None:
+ # Not a regression test with '-3', so try to use faster version.
+ try:
+ # Use the "imp" module to protect the import from fixers.
+ import imp
+ _cPickle = imp.load_module('cPickle', *imp.find_module('cPickle'))
+ except ImportError, e:
+ # The "cPickle" module has already been eliminated in favor of
+ # having "import pickle" import the fast version when available.
+ pass
+ else:
+ import sys
+ sys.modules['pickle'] = _cPickle
+ del _cPickle
try:
@@ -387,6 +392,24 @@ except AttributeError:
del mkstemp
+if os.environ.get('SCONS_HORRIBLE_REGRESSION_TEST_HACK') is not None:
+ # We can't apply the 'callable' fixer until the floor is 2.6, but the
+ # '-3' option to Python 2.6 and 2.7 generates almost ten thousand
+ # warnings. This hack allows us to run regression tests with the '-3'
+ # option by replacing the callable() built-in function with a hack
+ # that performs the same function but doesn't generate the warning.
+ # Note that this hack is ONLY intended to be used for regression
+ # testing, and should NEVER be used for real runs.
+ from types import ClassType
+ def callable(obj):
+ if hasattr(obj, '__call__'): return True
+ if isinstance(obj, (ClassType, type)): return True
+ return False
+ import builtins
+ builtins.callable = callable
+ del callable
+
+
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
diff --git a/src/engine/SCons/compat/_scons_builtins.py b/src/engine/SCons/compat/_scons_builtins.py
index 6a725c1..012d6c2 100644
--- a/src/engine/SCons/compat/_scons_builtins.py
+++ b/src/engine/SCons/compat/_scons_builtins.py
@@ -127,7 +127,7 @@ except NameError:
# Pre-2.2 Python has no False keyword.
builtins.False = not 1
# Assign to False in this module namespace so it shows up in pydoc output.
- False = False
+ #False = False
try:
True
@@ -135,7 +135,7 @@ except NameError:
# Pre-2.2 Python has no True keyword.
builtins.True = not 0
# Assign to True in this module namespace so it shows up in pydoc output.
- True = True
+ #True = True
try:
file
diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py
index 80b1c8b..9442942 100644
--- a/src/engine/SCons/cpp.py
+++ b/src/engine/SCons/cpp.py
@@ -133,7 +133,7 @@ CPP_to_Python_Ops_Sub = lambda m: CPP_to_Python_Ops_Dict[m.group(0)]
# re module, as late as version 2.2.2, empirically matches the
# "!" in "!=" first, instead of finding the longest match.
# What's up with that?
-l = sorted(CPP_to_Python_Ops_Dict.keys(), cmp=lambda a, b: cmp(len(b), len(a)))
+l = sorted(CPP_to_Python_Ops_Dict.keys(), key=lambda a: len(a), reverse=True)
# Turn the list of keys into one regular expression that will allow us
# to substitute all of the operators at once.
diff --git a/test/NodeOps.py b/test/NodeOps.py
index e4a403f..6de7d09 100644
--- a/test/NodeOps.py
+++ b/test/NodeOps.py
@@ -70,7 +70,7 @@ if %(_E)s:
real1 = [os.path.exists(str(N)) for N in Nodes]
exists = [N.exists() for N in Nodes]
real2 = [os.path.exists(str(N)) for N in Nodes]
- for N,D,R,E,F in map(None, Nodes, derived, real1, exists, real2):
+ for N,D,R,E,F in zip(Nodes, derived, real1, exists, real2):
print '%%s: %%s %%s %%s %%s'%%(N,D,R,E,F)
foo.SharedLibrary(target = 'foo', source = 'foo%(_obj)s')
bar.SharedLibrary(target = 'bar', source = 'bar%(_obj)s')
diff --git a/test/exitfns.py b/test/exitfns.py
index 3fc1322..f64969b 100644
--- a/test/exitfns.py
+++ b/test/exitfns.py
@@ -34,9 +34,9 @@ from SCons.exitfuncs import *
def x1():
print "running x1"
def x2(n):
- print "running x2(%s)" % `n`
+ print "running x2(%s)" % repr(n)
def x3(n, kwd=None):
- print "running x3(%s, kwd=%s)" % (`n`, `kwd`)
+ print "running x3(%s, kwd=%s)" % (repr(n), repr(kwd))
register(x3, "no kwd args")
register(x1)