summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-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
10 files changed, 49 insertions, 38 deletions
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.