http://scons.tigris.org/issues/show_bug.cgi?id=2345
authorgregnoel <gregnoel@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 16 Apr 2010 22:01:00 +0000 (22:01 +0000)
committergregnoel <gregnoel@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 16 Apr 2010 22:01:00 +0000 (22:01 +0000)
Quiet the rest of the 'callable' warnings and fix the rest of the 'cmp
argument' warnings.

git-svn-id: http://scons.tigris.org/svn/scons/trunk@4789 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Tool/msvs.py
src/script/scons-time.py
test/GetBuildFailures/option-k.py
test/Glob/source.py

index 304c35ea863bc78f9dd3eb40c106076837156ec1..e932351edb843aa13126805994348d7c96e5e483 100644 (file)
@@ -290,7 +290,9 @@ class _DSPGenerator:
                         self.sources[t[0]].append(self.env[t[1]])
 
         for n in sourcenames:
                         self.sources[t[0]].append(self.env[t[1]])
 
         for n in sourcenames:
-            self.sources[n].sort(lambda a, b: cmp(a.lower(), b.lower()))
+            #TODO 2.4: compat layer supports sorted(key=) but not sort(key=)
+            #TODO 2.4: self.sources[n].sort(key=lambda a: a.lower())
+            self.sources[n] = sorted(self.sources[n], key=lambda a: a.lower())
 
         def AddConfig(self, variant, buildtarget, outdir, runfile, cmdargs, dspfile=dspfile):
             config = Config()
 
         def AddConfig(self, variant, buildtarget, outdir, runfile, cmdargs, dspfile=dspfile):
             config = Config()
@@ -439,9 +441,7 @@ class _GenerateV6DSP(_DSPGenerator):
                       'Resource Files': 'r|rc|ico|cur|bmp|dlg|rc2|rct|bin|cnt|rtf|gif|jpg|jpeg|jpe',
                       'Other Files': ''}
 
                       'Resource Files': 'r|rc|ico|cur|bmp|dlg|rc2|rct|bin|cnt|rtf|gif|jpg|jpeg|jpe',
                       'Other Files': ''}
 
-        cats = categories.keys()
-        cats.sort(lambda a, b: cmp(a.lower(), b.lower()))
-        for kind in cats:
+        for kind in sorted(categories.keys(), key=lambda a: a.lower()):
             if not self.sources[kind]:
                 continue # skip empty groups
 
             if not self.sources[kind]:
                 continue # skip empty groups
 
@@ -695,8 +695,7 @@ class _GenerateV7DSP(_DSPGenerator):
             self.file.write(pdata + '-->\n')
 
     def printSources(self, hierarchy, commonprefix):
             self.file.write(pdata + '-->\n')
 
     def printSources(self, hierarchy, commonprefix):
-        sorteditems = hierarchy.items()
-        sorteditems.sort(lambda a, b: cmp(a[0].lower(), b[0].lower()))
+        sorteditems = sorted(hierarchy.items(), key=lambda a: a[0].lower())
 
         # First folders, then files
         for key, value in sorteditems:
 
         # First folders, then files
         for key, value in sorteditems:
@@ -726,9 +725,8 @@ class _GenerateV7DSP(_DSPGenerator):
 
         self.file.write('\t<Files>\n')
 
 
         self.file.write('\t<Files>\n')
 
-        cats = categories.keys()
-        cats.sort(lambda a, b: cmp(a.lower(), b.lower()))
-        cats = [k for k in cats if self.sources[k]]
+        cats = sorted([k for k in categories.keys() if self.sources[k]],
+                      key=lambda a: a.lower())
         for kind in cats:
             if len(cats) > 1:
                 self.file.write('\t\t<Filter\n'
         for kind in cats:
             if len(cats) > 1:
                 self.file.write('\t\t<Filter\n'
index fa04d3725aa5227db1f345b783ab7a42e37bc6c3..d85dc8eb81ed1be80a27e1eda93f35998be6bc30 100644 (file)
@@ -38,7 +38,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 import getopt
 import glob
 import os
 import getopt
 import glob
 import os
-import os.path
 import re
 import shutil
 import sys
 import re
 import shutil
 import sys
@@ -82,6 +81,20 @@ except NameError:
             result.reverse()
         return result
 
             result.reverse()
         return result
 
+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
+
 def make_temp_file(**kw):
     try:
         result = tempfile.mktemp(**kw)
 def make_temp_file(**kw):
     try:
         result = tempfile.mktemp(**kw)
index 53b57ff89a19a23864d7af06fb2863484a9c656a..300f69f9edf78a7ab4d2f8fedb48089e2a1eb983 100644 (file)
@@ -64,8 +64,7 @@ Command('f6', 'f6.in', r'@%(_python_)s mypass.py f5 -  $TARGET $SOURCE')
 
 def print_build_failures():
     from SCons.Script import GetBuildFailures
 
 def print_build_failures():
     from SCons.Script import GetBuildFailures
-    for bf in sorted(GetBuildFailures(),
-                     cmp=lambda a,b: cmp(a.filename, b.filename)):
+    for bf in sorted(GetBuildFailures(), key=lambda a: a.filename):
         print "%%s failed:  %%s" %% (bf.node, bf.errstr)
 
 try:
         print "%%s failed:  %%s" %% (bf.node, bf.errstr)
 
 try:
index afa17f565058654065349b551c4b2e4aa72dde4f..f1ea56667b7fb80e73f144ff2398ed14e7b398e3 100644 (file)
@@ -66,7 +66,7 @@ env.Concatenate('f.out', sorted(Glob('f[45].in', source=True),
 test.write(['var2', 'SConscript'], """\
 Import("env")
 
 test.write(['var2', 'SConscript'], """\
 Import("env")
 
-f_in = sorted(Glob('f[67].in'), cmp=lambda a,b: cmp(a.name, b.name))
+f_in = sorted(Glob('f[67].in'), key=lambda a: a.name)
 env.Concatenate('f.out', f_in)
 """)
 
 env.Concatenate('f.out', f_in)
 """)