Issue 2401: Fix usage of comparison with None, patch from Jared Grubb
authorgregnoel <gregnoel@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 3 May 2009 06:24:01 +0000 (06:24 +0000)
committergregnoel <gregnoel@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 3 May 2009 06:24:01 +0000 (06:24 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@4170 fdb21ef1-2011-0410-befe-b5e4ea1792b1

30 files changed:
src/CHANGES.txt
src/engine/SCons/ActionTests.py
src/engine/SCons/BuilderTests.py
src/engine/SCons/Defaults.py
src/engine/SCons/Environment.py
src/engine/SCons/EnvironmentTests.py
src/engine/SCons/ErrorsTests.py
src/engine/SCons/Node/AliasTests.py
src/engine/SCons/Node/FSTests.py
src/engine/SCons/Node/NodeTests.py
src/engine/SCons/Node/Python.py
src/engine/SCons/Node/__init__.py
src/engine/SCons/Platform/posix.py
src/engine/SCons/Platform/win32.py
src/engine/SCons/SConf.py
src/engine/SCons/SConfTests.py
src/engine/SCons/Scanner/__init__.py
src/engine/SCons/Script/Main.py
src/engine/SCons/TaskmasterTests.py
src/engine/SCons/Tool/JavaCommonTests.py
src/engine/SCons/Tool/tex.py
src/engine/SCons/Util.py
src/engine/SCons/UtilTests.py
src/engine/SCons/Variables/BoolVariableTests.py
src/engine/SCons/Variables/EnumVariableTests.py
src/engine/SCons/Variables/PackageVariableTests.py
src/engine/SCons/Variables/PathVariableTests.py
src/engine/SCons/Variables/VariablesTests.py
src/script/scons-time.py
src/test_interrupts.py

index 846a57b85291490a5781046361470a9316a12822..427d50907b19838afd8a73c850d1d2d71accb1a7 100644 (file)
@@ -240,6 +240,8 @@ RELEASE 1.1.0.d20081207 - Sun, 07 Dec 2008 19:17:23 -0800
 
     - Fix a typo in the documentation for $_CPPDEFFLAGS.
 
+    - Issue 2401: Fix usage of comparisons with None.
+
   From Ludwig Hähne:
 
     - Handle Java inner classes declared within a method.
index 3571980d7c98db323580ac7062a34dcd20c8d16c..b3f52217d0473b51d08de2b2cdc5a09dc63ea0f1 100644 (file)
@@ -262,7 +262,7 @@ def test_positional_args(pos_callback, cmd, **kw):
 
         def none(a):
             assert hasattr(a, 'strfunction')
-            assert a.cmdstr == None, a.cmdstr
+            assert a.cmdstr is None, a.cmdstr
         #FUTURE test_varlist(pos_callback, none, cmd, None, **kw)
         apply(test_varlist, (pos_callback, none, cmd, None), kw)
 
index 8bb416996b85f7a98810b4dd24dd2c65debca7fc..b72b1338652eb213f6ca3cb91ed51896e91e747a 100644 (file)
@@ -1108,7 +1108,7 @@ class BuilderTestCase(unittest.TestCase):
         r = builder.get_prefix(env)
         assert r == 'A_', r
         r = builder.get_suffix(env)
-        assert r == None, r
+        assert r is None, r
         r = builder.get_src_suffix(env)
         assert r == '', r
         r = builder.src_suffixes(env)
@@ -1127,9 +1127,9 @@ class BuilderTestCase(unittest.TestCase):
         r = builder.get_prefix(env)
         assert r == 'A_', r
         r = builder.get_suffix(env)
-        assert r == None, r
+        assert r is None, r
         r = builder.get_suffix(env, [MyNode('X.src_sfx1')])
-        assert r == None, r
+        assert r is None, r
         r = builder.get_src_suffix(env)
         assert r == '.src_sfx1', r
         r = builder.src_suffixes(env)
@@ -1145,7 +1145,7 @@ class BuilderTestCase(unittest.TestCase):
         r = builder.get_prefix(env)
         assert r == 'A_', r
         r = builder.get_suffix(env)
-        assert r ==  None, r
+        assert r is None, r
         r = builder.get_src_suffix(env)
         assert r == '.src_sfx1', r
         r = builder.src_suffixes(env)
index 7d44e38f6103174e79c5b52b3bd825f71d5bc655..a3acc52d80f52b6e3cd23cb50273472382d37f5b 100644 (file)
@@ -273,7 +273,7 @@ def _concat(prefix, list, suffix, env, f=lambda x: x, target=None, source=None):
         return list
 
     l = f(SCons.PathList.PathList(list).subst_path(env, target, source))
-    if not l is None:
+    if l is not None:
         list = l
 
     return _concat_ixes(prefix, list, suffix, env)
index 37dd3b42867d7a3e7450d4a9de069242a14ed55a..80d8516d54e4220f3842fe4ce4e486e9ee100cb6 100644 (file)
@@ -245,9 +245,9 @@ class BuilderWrapper(MethodWrapper):
         if source is _null:
             source = target
             target = None
-        if not target is None and not SCons.Util.is_List(target):
+        if target is not None and not SCons.Util.is_List(target):
             target = [target]
-        if not source is None and not SCons.Util.is_List(source):
+        if source is not None and not SCons.Util.is_List(source):
             source = [source]
         return apply(MethodWrapper.__call__, (self, target, source) + args, kw)
 
@@ -457,9 +457,9 @@ class SubstitutionEnvironment:
                 n = None
                 for l in lookup_list:
                     n = l(v)
-                    if not n is None:
+                    if n is not None:
                         break
-                if not n is None:
+                if n is not None:
                     if SCons.Util.is_String(n):
                         # n = self.subst(n, raw=1, **kw)
                         kw['raw'] = 1
@@ -1822,7 +1822,7 @@ class Base(SubstitutionEnvironment):
 
     def CacheDir(self, path):
         import SCons.CacheDir
-        if not path is None:
+        if path is not None:
             path = self.subst(path)
         self._CacheDir_path = path
 
@@ -2013,7 +2013,7 @@ class Base(SubstitutionEnvironment):
         return apply(SCons.Scanner.Base, nargs, nkw)
 
     def SConsignFile(self, name=".sconsign", dbm_module=None):
-        if not name is None:
+        if name is not None:
             name = self.subst(name)
             if not os.path.isabs(name):
                 name = os.path.join(str(self.fs.SConstruct_dir), name)
index 27ede15da0793cfa48804720329b43138ebf4f5a..6d916209c8f07ea60597e9162752c9df9e7c2011 100644 (file)
@@ -956,20 +956,20 @@ class BaseTestCase(unittest.TestCase,TestEnvironmentFixture):
                                  'builder2' : b2 })
         called_it = {}
         env.builder1('in1')
-        assert called_it['target'] == None, called_it
+        assert called_it['target'] is None, called_it
         assert called_it['source'] == ['in1'], called_it
 
         called_it = {}
         env.builder2(source = 'in2', xyzzy = 1)
-        assert called_it['target'] == None, called_it
+        assert called_it['target'] is None, called_it
         assert called_it['source'] == ['in2'], called_it
         assert called_it['xyzzy'] == 1, called_it
 
         called_it = {}
         env.builder1(foo = 'bar')
         assert called_it['foo'] == 'bar', called_it
-        assert called_it['target'] == None, called_it
-        assert called_it['source'] == None, called_it
+        assert called_it['target'] is None, called_it
+        assert called_it['source'] is None, called_it
 
     def test_BuilderWrapper_attributes(self):
         """Test getting and setting of BuilderWrapper attributes
@@ -1976,12 +1976,12 @@ def generate(env):
 
         assert paths[0] == env.FindIxes(paths, 'LIBPREFIX', 'LIBSUFFIX')
         assert paths[1] == env.FindIxes(paths, 'SHLIBPREFIX', 'SHLIBSUFFIX')
-        assert None == env.FindIxes(paths, 'PREFIX', 'POST')
+        assert None is env.FindIxes(paths, 'PREFIX', 'POST')
 
         paths = ['libfoo.a', 'prefoopost']
 
         assert paths[0] == env.FindIxes(paths, 'LIBPREFIX', 'LIBSUFFIX')
-        assert None == env.FindIxes(paths, 'SHLIBPREFIX', 'SHLIBSUFFIX')
+        assert None is env.FindIxes(paths, 'SHLIBPREFIX', 'SHLIBSUFFIX')
         assert paths[1] == env.FindIxes(paths, 'PREFIX', 'SUFFIX')
 
     def test_ParseConfig(self):
@@ -2729,20 +2729,20 @@ def generate(env):
         env = self.TestEnvironment(FOO = 'xyzzy')
 
         b = env.Builder(action = 'foo')
-        assert not b is None, b
+        assert b is not None, b
 
         b = env.Builder(action = '$FOO')
-        assert not b is None, b
+        assert b is not None, b
 
         b = env.Builder(action = ['$FOO', 'foo'])
-        assert not b is None, b
+        assert b is not None, b
 
         def func(arg):
             pass
         b = env.Builder(action = func)
-        assert not b is None, b
+        assert b is not None, b
         b = env.Builder(generator = func)
-        assert not b is None, b
+        assert b is not None, b
 
     def test_CacheDir(self):
         """Test the CacheDir() method"""
@@ -2785,7 +2785,7 @@ def generate(env):
         env = Environment()
         t = env.Command(target='foo.out', source=['foo1.in', 'foo2.in'],
                         action='buildfoo $target $source')[0]
-        assert not t.builder is None
+        assert t.builder is not None
         assert t.builder.action.__class__.__name__ == 'CommandAction'
         assert t.builder.action.cmd_list == 'buildfoo $target $source'
         assert 'foo1.in' in map(lambda x: x.path, t.sources)
@@ -2802,7 +2802,7 @@ def generate(env):
             return 0
         t = env.Command(target='foo.out', source=['foo1.in','foo2.in'],
                         action=testFunc)[0]
-        assert not t.builder is None
+        assert t.builder is not None
         assert t.builder.action.__class__.__name__ == 'FunctionAction'
         t.build()
         assert 'foo1.in' in map(lambda x: x.path, t.sources)
@@ -2815,7 +2815,7 @@ def generate(env):
         t = env.Command(target='baz.out', source='baz.in',
                         action='${TEST2(XYZ)}',
                         XYZ='magic word')[0]
-        assert not t.builder is None
+        assert t.builder is not None
         t.build()
         assert x[0] == 'magic word', x
 
@@ -2846,11 +2846,11 @@ def generate(env):
                 pass
 
             c = env.Configure()
-            assert not c is None, c
+            assert c is not None, c
             c.Finish()
 
             c = env.Configure(custom_tests = {'foo' : func, '$FOO' : func})
-            assert not c is None, c
+            assert c is not None, c
             assert hasattr(c, 'foo')
             assert hasattr(c, 'xyzzy')
             c.Finish()
@@ -3139,17 +3139,17 @@ def generate(env):
         env = self.TestEnvironment(FOO = scan)
 
         s = env.Scanner('foo')
-        assert not s is None, s
+        assert s is not None, s
 
         s = env.Scanner(function = 'foo')
-        assert not s is None, s
+        assert s is not None, s
 
         if 0:
             s = env.Scanner('$FOO')
-            assert not s is None, s
+            assert s is not None, s
 
             s = env.Scanner(function = '$FOO')
-            assert not s is None, s
+            assert s is not None, s
 
     def test_SConsignFile(self):
         """Test the SConsignFile() method"""
@@ -3175,19 +3175,19 @@ def generate(env):
 
             env.SConsignFile('foo')
             assert fnames[-1] == os.path.join(os.sep, 'dir', 'foo'), fnames
-            assert dbms[-1] == None, dbms
+            assert dbms[-1] is None, dbms
 
             env.SConsignFile('$FOO')
             assert fnames[-1] == os.path.join(os.sep, 'dir', 'SConsign'), fnames
-            assert dbms[-1] == None, dbms
+            assert dbms[-1] is None, dbms
 
             env.SConsignFile('/$FOO')
             assert fnames[-1] == os.sep + 'SConsign', fnames
-            assert dbms[-1] == None, dbms
+            assert dbms[-1] is None, dbms
 
             env.SConsignFile(os.sep + '$FOO')
             assert fnames[-1] == os.sep + 'SConsign', fnames
-            assert dbms[-1] == None, dbms
+            assert dbms[-1] is None, dbms
 
             env.SConsignFile('$BAR', 'x')
             assert fnames[-1] == os.path.join(os.sep, 'File'), fnames
@@ -3199,11 +3199,11 @@ def generate(env):
 
             env.SConsignFile()
             assert fnames[-1] == os.path.join(os.sep, 'dir', '.sconsign'), fnames
-            assert dbms[-1] == None, dbms
+            assert dbms[-1] is None, dbms
 
             env.SConsignFile(None)
-            assert fnames[-1] == None, fnames
-            assert dbms[-1] == None, dbms
+            assert fnames[-1] is None, fnames
+            assert dbms[-1] is None, dbms
         finally:
             SCons.SConsign.File = save_SConsign_File
 
@@ -3611,8 +3611,8 @@ class OverrideEnvironmentTestCase(unittest.TestCase,TestEnvironmentFixture):
         assert env.get('YYY') == 'y', env.get('YYY')
         assert env2.get('YYY') == 'y', env2.get('YYY')
         assert env3.get('YYY') == 'y3', env3.get('YYY')
-        assert env.get('ZZZ') == None, env.get('ZZZ')
-        assert env2.get('ZZZ') == None, env2.get('ZZZ')
+        assert env.get('ZZZ') is None, env.get('ZZZ')
+        assert env2.get('ZZZ') is None, env2.get('ZZZ')
         assert env3.get('ZZZ') == 'z3', env3.get('ZZZ')
 
     def test_has_key(self):
@@ -3937,15 +3937,15 @@ class EnvironmentVariableTestCase(unittest.TestCase):
     def test_is_valid_construction_var(self):
         """Testing is_valid_construction_var()"""
         r = is_valid_construction_var("_a")
-        assert not r is None, r
+        assert r is not None, r
         r = is_valid_construction_var("z_")
-        assert not r is None, r
+        assert r is not None, r
         r = is_valid_construction_var("X_")
-        assert not r is None, r
+        assert r is not None, r
         r = is_valid_construction_var("2a")
         assert r is None, r
         r = is_valid_construction_var("a2_")
-        assert not r is None, r
+        assert r is not None, r
         r = is_valid_construction_var("/")
         assert r is None, r
         r = is_valid_construction_var("_/")
index 40285e4d7695b776a36578029d6d8deffc75d33e..1eee6e1b660b90eba90a78c952c312423588665b 100644 (file)
@@ -68,13 +68,13 @@ class ErrorsTestCase(unittest.TestCase):
             assert e.errstr == "Unknown error"
             assert e.status == 2
             assert e.exitstatus == 2
-            assert e.filename == None
+            assert e.filename is None
             assert e.exc_info == (None, None, None)
 
-            assert e.node == None
-            assert e.executor == None
-            assert e.action == None
-            assert e.command == None
+            assert e.node is None
+            assert e.executor is None
+            assert e.action is None
+            assert e.command is None
 
     def test_InternalError(self):
         """Test the InternalError exception."""
index 184e710433d39c12ea88e6dc73607c9ad48d02da..82322e3b834f2816dfbad9779f5cb8a4affe7005 100644 (file)
@@ -35,7 +35,7 @@ class AliasTestCase(unittest.TestCase):
         """Test creating an Alias name space
         """
         ans = SCons.Node.Alias.AliasNameSpace()
-        assert not ans is None, ans
+        assert ans is not None, ans
 
     def test_ANS_Alias(self):
         """Test the Alias() factory
@@ -82,7 +82,7 @@ class AliasTestCase(unittest.TestCase):
         assert a is a1, a1
 
         a = ans.lookup('a2')
-        assert a == None, a
+        assert a is None, a
 
     def test_Alias(self):
         """Test creating an Alias() object
index 642d7019539c910c75fcc6858fb8910c35af9d18..cb2bd68a3d341538cb144e4eb17bdc6150edb10b 100644 (file)
@@ -611,7 +611,7 @@ class BaseTestCase(_tempdirTestCase):
 
         e1 = fs.Entry('e1')
         s = e1.stat()
-        assert not s is None, s
+        assert s is not None, s
 
         e2 = fs.Entry('e2')
         s = e2.stat()
@@ -1386,7 +1386,7 @@ class FSTestCase(_tempdirTestCase):
 
         f = fs.File('does_not_exist')
         r = f.remove()
-        assert r == None, r
+        assert r is None, r
 
         test.write('exists', "exists\n")
         f = fs.File('exists')
index 4612d3f796e21c583b62ca9032980a493bd14145..643e2184f78958a897098887739840d3378c6188 100644 (file)
@@ -295,9 +295,9 @@ class NodeTestCase(unittest.TestCase):
         # Make sure it doesn't blow up if no builder is set.
         node = MyNode("www")
         node.build()
-        assert built_it == None
+        assert built_it is None
         node.build(extra_kw_argument = 1)
-        assert built_it == None
+        assert built_it is None
 
         node = MyNode("xxx")
         node.builder_set(Builder())
@@ -522,7 +522,7 @@ class NodeTestCase(unittest.TestCase):
         n = SCons.Node.Node()
         t, m = n.alter_targets()
         assert t == [], t
-        assert m == None, m
+        assert m is None, m
 
     def test_is_up_to_date(self):
         """Test the default is_up_to_date() method
@@ -622,7 +622,7 @@ class NodeTestCase(unittest.TestCase):
         node.fs = FS()
         node.fs.Top = SCons.Node.Node()
         result = node.explain()
-        assert result == None, result
+        assert result is None, result
 
         def get_null_info():
             class Null_SConsignEntry:
@@ -1020,7 +1020,7 @@ class NodeTestCase(unittest.TestCase):
 
     def test_scanner_key(self):
         """Test that a scanner_key() method exists"""
-        assert SCons.Node.Node().scanner_key() == None
+        assert SCons.Node.Node().scanner_key() is None
 
     def test_children(self):
         """Test fetching the non-ignored "children" of a Node.
@@ -1104,7 +1104,7 @@ class NodeTestCase(unittest.TestCase):
         assert not nw.is_done()
         assert nw.next().name ==  "n1"
         assert nw.is_done()
-        assert nw.next() == None
+        assert nw.next() is None
 
         n2 = MyNode("n2")
         n3 = MyNode("n3")
@@ -1118,7 +1118,7 @@ class NodeTestCase(unittest.TestCase):
         n = nw.next()
         assert n.name ==  "n1", n.name
         n = nw.next()
-        assert n == None, n
+        assert n is None, n
 
         n4 = MyNode("n4")
         n5 = MyNode("n5")
@@ -1138,7 +1138,7 @@ class NodeTestCase(unittest.TestCase):
         assert nw.next().name ==  "n3"
         assert nw.history.has_key(n1)
         assert nw.next().name ==  "n1"
-        assert nw.next() == None
+        assert nw.next() is None
 
         n8 = MyNode("n8")
         n8.add_dependency([n3])
@@ -1160,7 +1160,7 @@ class NodeTestCase(unittest.TestCase):
         n = nw.next()
         assert n.name == "n7", n.name
         n = nw.next()
-        assert nw.next() == None
+        assert nw.next() is None
 
     def test_abspath(self):
         """Test the get_abspath() method."""
index c44359495eba678c4cdbf157ac8dd34925cd58a4..eba008b6ad5798d9787b1fdd43c97b50c3861223 100644 (file)
@@ -53,7 +53,7 @@ class Value(SCons.Node.Node):
     def __init__(self, value, built_value=None):
         SCons.Node.Node.__init__(self)
         self.value = value
-        if not built_value is None:
+        if built_value is not None:
             self.built_value = built_value
 
     def str_for_display(self):
index ee9083ce267c3774048a259876a59f5b9090cdc2..c4f36cca09526cb963a58fcba7222fd5323f9497 100644 (file)
@@ -352,7 +352,7 @@ class Node:
             if d.missing():
                 msg = "Explicit dependency `%s' not found, needed by target `%s'."
                 raise SCons.Errors.StopError, msg % (d, self)
-        if not self.implicit is None:
+        if self.implicit is not None:
             for i in self.implicit:
                 if i.missing():
                     msg = "Implicit dependency `%s' not found, needed by target `%s'."
@@ -474,7 +474,7 @@ class Node:
             # There was no explicit builder for this Node, so initialize
             # the self.builder attribute to None now.
             b = self.builder = None
-        return not b is None
+        return b is not None
 
     def set_explicit(self, is_explicit):
         self.is_explicit = is_explicit
@@ -602,7 +602,7 @@ class Node:
         # Don't bother scanning non-derived files, because we don't
         # care what their dependencies are.
         # Don't scan again, if we already have scanned.
-        if not self.implicit is None:
+        if self.implicit is not None:
             return
         self.implicit = []
         self.implicit_set = set()
@@ -891,7 +891,7 @@ class Node:
 
     def add_wkid(self, wkid):
         """Add a node to the list of kids waiting to be evaluated"""
-        if self.wkids != None:
+        if self.wkids is not None:
             self.wkids.append(wkid)
 
     def _children_reset(self):
index f18569ffaa63ee2aa9f40aea2cdf5f5e1a348ce6..d1102b35f57a3b20b684e5bb379137ec435bcc9f 100644 (file)
@@ -116,7 +116,7 @@ def process_cmd_output(cmd_stdout, cmd_stderr, stdout, stderr):
                 str = cmd_stdout.read()
                 if len(str) == 0:
                     stdout_eof = 1
-                elif stdout != None:
+                elif stdout is not None:
                     stdout.write(str)
             if cmd_stderr in i:
                 str = cmd_stderr.read()
index fb23d5d8fcef62d04113d91329e7546501909790..1dc7f3cba37bff6de34d316b8cf7210fee6bcf10 100644 (file)
@@ -134,18 +134,18 @@ def piped_spawn(sh, escape, cmd, args, env, stdout, stderr):
                 ret = exitvalmap[e[0]]
             except KeyError:
                 sys.stderr.write("scons: unknown OSError exception code %d - %s: %s\n" % (e[0], cmd, e[1]))
-            if stderr != None:
+            if stderr is not None:
                 stderr.write("scons: %s: %s\n" % (cmd, e[1]))
         # copy child output from tempfiles to our streams
         # and do clean up stuff
-        if stdout != None and stdoutRedirected == 0:
+        if stdout is not None and stdoutRedirected == 0:
             try:
                 stdout.write(open( tmpFileStdout, "r" ).read())
                 os.remove( tmpFileStdout )
             except (IOError, OSError):
                 pass
 
-        if stderr != None and stderrRedirected == 0:
+        if stderr is not None and stderrRedirected == 0:
             try:
                 stderr.write(open( tmpFileStderr, "r" ).read())
                 os.remove( tmpFileStderr )
index 5d671d2fd1ecd49c62a41a91fc6b584edf088b93..8586402879128739eb15555427ef5070eb2a848e 100644 (file)
@@ -398,11 +398,11 @@ class SConfBase:
         if not SConfFS:
             SConfFS = SCons.Node.FS.default_fs or \
                       SCons.Node.FS.FS(env.fs.pathTop)
-        if not sconf_global is None:
+        if sconf_global is not None:
             raise (SCons.Errors.UserError,
                    "Only one SConf object may be active at one time")
         self.env = env
-        if log_file != None:
+        if log_file is not None:
             log_file = SConfFS.File(env.subst(log_file))
         self.logfile = log_file
         self.logstream = None
@@ -429,7 +429,7 @@ class SConfBase:
         self.AddTests(default_tests)
         self.AddTests(custom_tests)
         self.confdir = SConfFS.Dir(env.subst(conf_dir))
-        if not config_h is None:
+        if config_h is not None:
             config_h = SConfFS.File(config_h)
         self.config_h = config_h
         self._startup()
@@ -471,7 +471,7 @@ class SConfBase:
         Tries to build the given nodes immediately. Returns 1 on success,
         0 on error.
         """
-        if self.logstream != None:
+        if self.logstream is not None:
             # override stdout / stderr to write in log file
             oldStdout = sys.stdout
             sys.stdout = self.logstream
@@ -510,7 +510,7 @@ class SConfBase:
             SConfFS.set_max_drift(save_max_drift)
             os.chdir(old_os_dir)
             SConfFS.chdir(old_fs_dir, change_os_dir=0)
-            if self.logstream != None:
+            if self.logstream is not None:
                 # restore stdout / stderr
                 sys.stdout = oldStdout
                 sys.stderr = oldStderr
@@ -559,7 +559,7 @@ class SConfBase:
             self.env['SPAWN'] = self.pspawn_wrapper
             sourcetext = self.env.Value(text)
 
-            if text != None:
+            if text is not None:
                 textFile = self.confdir.File(f + extension)
                 textFileNode = self.env.SConfSourceBuilder(target=textFile,
                                                            source=sourcetext)
@@ -645,7 +645,7 @@ class SConfBase:
                        "Test called after sconf.Finish()")
             context = CheckContext(self.sconf)
             ret = apply(self.test, (context,) +  args, kw)
-            if not self.sconf.config_h is None:
+            if self.sconf.config_h is not None:
                 self.sconf.config_h_text = self.sconf.config_h_text + context.config_h
             context.Result("error: no result")
             return ret
@@ -685,7 +685,7 @@ class SConfBase:
         self._createDir(self.confdir)
         self.confdir.up().add_ignore( [self.confdir] )
 
-        if self.logfile != None and not dryrun:
+        if self.logfile is not None and not dryrun:
             # truncate logfile, if SConf.Configure is called for the first time
             # in a build
             if _ac_config_logs.has_key(self.logfile):
@@ -724,7 +724,7 @@ class SConfBase:
 
         if not self.active:
             raise SCons.Errors.UserError, "Finish may be called only once!"
-        if self.logstream != None and not dryrun:
+        if self.logstream is not None and not dryrun:
             self.logstream.write("\n")
             self.logstream.close()
             self.logstream = None
@@ -869,7 +869,7 @@ class CheckContext:
         self.Log("scons: Configure: " + msg + "\n")
 
     def Log(self, msg):
-        if self.sconf.logstream != None:
+        if self.sconf.logstream is not None:
             self.sconf.logstream.write(msg)
 
     #### End of stuff used by Conftest.py.
index 2fa173d930ee5b0c2fe7cae9aa5d9190381dd369..5315ea30d1450672372a70a8ff2ace4b0c2a9ae7 100644 (file)
@@ -141,9 +141,9 @@ class SConfTestCase(unittest.TestCase):
         log = self.test.read( self.test.workpath('config.log') )
         expr = re.compile( ".*failed in a previous run and all", re.DOTALL ) 
         firstOcc = expr.match( log )
-        assert firstOcc != None, log
+        assert firstOcc is not None, log
         secondOcc = expr.match( log, firstOcc.end(0) )
-        assert secondOcc == None, log
+        assert secondOcc is None, log
 
         # 2.2 test the error caching mechanism (dependencies have changed)
         self._resetSConfState()
@@ -285,9 +285,9 @@ int main() {
         log = self.test.read( self.test.workpath('config.log') )
         expr = re.compile( ".*failed in a previous run and all", re.DOTALL )
         firstOcc = expr.match( log )
-        assert firstOcc != None, log
+        assert firstOcc is not None, log
         secondOcc = expr.match( log, firstOcc.end(0) )
-        assert secondOcc == None, log
+        assert secondOcc is None, log
 
 
     def test_TryAction(self):
index c0d84b97e85b158f4ca21f077addc1a7a626783c..d0c7d3c5a69114f90266da6ac53632b5df39ab6b 100644 (file)
@@ -352,7 +352,7 @@ class Classic(Current):
     def scan(self, node, path=()):
 
         # cache the includes list in node so we only scan it once:
-        if node.includes != None:
+        if node.includes is not None:
             includes = node.includes
         else:
             includes = self.find_include_names (node)
index 44ca8772367b3a2e03c16df2ebd43450cb99cc5e..21fdc249c7f5858d9c4b3699fc3b0fddc48fc40c 100644 (file)
@@ -1101,14 +1101,14 @@ def _build_targets(fs, options, targets, target_top):
         else:
             node = None
             # Why would ltop be None? Unfortunately this happens.
-            if ltop == None: ltop = ''
+            if ltop is None: ltop = ''
             # Curdir becomes important when SCons is called with -u, -C,
             # or similar option that changes directory, and so the paths
             # of targets given on the command line need to be adjusted.
             curdir = os.path.join(os.getcwd(), str(ltop))
             for lookup in SCons.Node.arg2nodes_lookups:
                 node = lookup(x, curdir=curdir)
-                if node != None:
+                if node is not None:
                     break
             if node is None:
                 node = fs.Entry(x, directory=ltop, create=1)
index 6c8023020753441f92734641a1b56ffbde03ad06..7137967ee3dac88e73240fcd82cb95d43d8f6ec7 100644 (file)
@@ -207,7 +207,7 @@ class TaskmasterTestCase(unittest.TestCase):
         t.prepare()
         t.execute()
         t = tm.next_task()
-        assert t == None
+        assert t is None
 
         n1 = Node("n1")
         n2 = Node("n2")
@@ -236,7 +236,7 @@ class TaskmasterTestCase(unittest.TestCase):
         t.executed()
         t.postprocess()
 
-        assert tm.next_task() == None
+        assert tm.next_task() is None
 
         built_text = "up to date: "
         top_node = n3
@@ -281,7 +281,7 @@ class TaskmasterTestCase(unittest.TestCase):
         t.executed()
         t.postprocess()
 
-        assert tm.next_task() == None
+        assert tm.next_task() is None
 
 
         n1 = Node("n1")
@@ -316,13 +316,13 @@ class TaskmasterTestCase(unittest.TestCase):
         t5.executed()
         t5.postprocess()
 
-        assert tm.next_task() == None
+        assert tm.next_task() is None
 
 
         n4 = Node("n4")
         n4.set_state(SCons.Node.executed)
         tm = SCons.Taskmaster.Taskmaster([n4])
-        assert tm.next_task() == None
+        assert tm.next_task() is None
 
         n1 = Node("n1")
         n2 = Node("n2", [n1])
@@ -331,7 +331,7 @@ class TaskmasterTestCase(unittest.TestCase):
         t.executed()
         t.postprocess()
         t = tm.next_task()
-        assert tm.next_task() == None
+        assert tm.next_task() is None
 
 
         n1 = Node("n1")
@@ -353,7 +353,7 @@ class TaskmasterTestCase(unittest.TestCase):
         assert target == n3, target
         t.executed()
         t.postprocess()
-        assert tm.next_task() == None
+        assert tm.next_task() is None
 
         n1 = Node("n1")
         n2 = Node("n2")
@@ -379,14 +379,14 @@ class TaskmasterTestCase(unittest.TestCase):
         assert t.get_target() == n4
         t.executed()
         t.postprocess()
-        assert tm.next_task() == None
+        assert tm.next_task() is None
         assert scan_called == 4, scan_called
 
         tm = SCons.Taskmaster.Taskmaster([n5])
         t = tm.next_task()
         assert t.get_target() == n5, t.get_target()
         t.executed()
-        assert tm.next_task() == None
+        assert tm.next_task() is None
         assert scan_called == 5, scan_called
 
         n1 = Node("n1")
index f4a43efbb6646fca31075d109a4a11bd461cbdc1..1d01087963450dad53cbc15ba510526d05ccd85a 100644 (file)
@@ -75,7 +75,7 @@ public class BadDep {
 }
 """
         pkg_dir, classes = SCons.Tool.JavaCommon.parse_java(input)
-        assert pkg_dir == None, pkg_dir
+        assert pkg_dir is None, pkg_dir
         assert classes == ['BadDep'], classes
 
 
@@ -246,7 +246,7 @@ public class Test {
 """
 
         pkg_dir, classes = SCons.Tool.JavaCommon.parse_java(input)
-        assert pkg_dir == None, pkg_dir
+        assert pkg_dir is None, pkg_dir
         assert classes == ['Test'], classes
 
 
@@ -265,7 +265,7 @@ public class MyTabs
 """
 
         pkg_dir, classes = SCons.Tool.JavaCommon.parse_java(input)
-        assert pkg_dir == None, pkg_dir
+        assert pkg_dir is None, pkg_dir
         assert classes == ['MyTabs$MyInternal', 'MyTabs'], classes
 
 
@@ -302,7 +302,7 @@ public abstract class TestClass
 """
 
         pkg_dir, classes = SCons.Tool.JavaCommon.parse_java(input)
-        assert pkg_dir == None, pkg_dir
+        assert pkg_dir is None, pkg_dir
         assert classes == ['TestClass$1', 'TestClass$2', 'TestClass'], classes
 
 
@@ -320,7 +320,7 @@ class Foo { }
 """
 
         pkg_dir, classes = SCons.Tool.JavaCommon.parse_java(input)
-        assert pkg_dir == None, pkg_dir
+        assert pkg_dir is None, pkg_dir
         assert classes == ['TestSCons', 'Foo'], classes
 
 
@@ -354,7 +354,7 @@ public class A {
 """
 
         pkg_dir, classes = SCons.Tool.JavaCommon.parse_java(input)
-        assert pkg_dir == None, pkg_dir
+        assert pkg_dir is None, pkg_dir
         assert classes == ['A$B', 'A'], classes
 
     def test_anonymous_classes_with_parentheses(self):
index e0353b91a9fa0897fe6300325d47cf30faef519b..3473f8b2991798f7cea36a6f4a923a13686b0b32 100644 (file)
@@ -431,7 +431,7 @@ def ScanFiles(theFile, target, paths, file_tests, file_tests_search, env, graphi
         print " scanning ",str(theFile)
 
     for i in range(len(file_tests_search)):
-        if file_tests[i][0] == None:
+        if file_tests[i][0] is None:
             file_tests[i][0] = file_tests_search[i].search(content)
 
     # recursively call this on each of the included files
@@ -444,7 +444,7 @@ def ScanFiles(theFile, target, paths, file_tests, file_tests_search, env, graphi
 
     for src in inc_files:
         srcNode = srcNode = FindFile(src,['.tex','.ltx','.latex'],paths,env,requireExt=False)
-        if srcNode != None:
+        if srcNode is not None:
             file_test = ScanFiles(srcNode, target, paths, file_tests, file_tests_search, env, graphics_extensions, targetdir)
     if Verbose:
         print " done scanning ",str(theFile)
index c77ee495dd7f41b84f2df91de482f23d91748805..ac949a07db0970ae2bbae8383735d316ba7be153 100644 (file)
@@ -1127,7 +1127,7 @@ class Selector(OrderedDict):
             # the dictionary before giving up.
             s_dict = {}
             for (k,v) in self.items():
-                if not k is None:
+                if k is not None:
                     s_k = env.subst(k)
                     if s_dict.has_key(s_k):
                         # We only raise an error when variables point
index b76ba997f4e26977fe3b73a9ded5655a07d2759b..ee2c89834a0c79e8bca44c81dbaba49b74faa6dc 100644 (file)
@@ -625,13 +625,13 @@ class UtilTestCase(unittest.TestCase):
 
         s = Selector({'.d' : 'DDD', '.e' : 'EEE'})
         ret = s(env, [])
-        assert ret == None, ret
+        assert ret is None, ret
         ret = s(env, [MyNode('foo.d')])
         assert ret == 'DDD', ret
         ret = s(env, [MyNode('bar.e')])
         assert ret == 'EEE', ret
         ret = s(env, [MyNode('bar.x')])
-        assert ret == None, ret
+        assert ret is None, ret
         s[None] = 'XXX'
         ret = s(env, [MyNode('bar.x')])
         assert ret == 'XXX', ret
index 88f64ed1de5f824ac64ebe8cbe9bee7367d01b27..8ffb0795d250cecf9de4bc9cb251f942a9a2c4ba 100644 (file)
@@ -39,8 +39,8 @@ class BoolVariableTestCase(unittest.TestCase):
         assert o.key == 'test', o.key
         assert o.help == 'test option help (yes|no)', o.help
         assert o.default == 0, o.default
-        assert not o.validator is None, o.validator
-        assert not o.converter is None, o.converter
+        assert o.validator is not None, o.validator
+        assert o.converter is not None, o.converter
 
     def test_converter(self):
         """Test the BoolVariable converter"""
index cc9289a692c4beb53b7f02f7915dc56e77ae36d5..f4b600d738460638024bf6d3a158ae5d3d9159fb 100644 (file)
@@ -41,8 +41,8 @@ class EnumVariableTestCase(unittest.TestCase):
         assert o.key == 'test', o.key
         assert o.help == 'test option help (one|two|three)', o.help
         assert o.default == 0, o.default
-        assert not o.validator is None, o.validator
-        assert not o.converter is None, o.converter
+        assert o.validator is not None, o.validator
+        assert o.converter is not None, o.converter
 
     def test_converter(self):
         """Test the EnumVariable converter"""
index 190357ee475d4d885b1f988b47a4b05c047d6e30..2a9334841b7d99df99553d922796a0251db532d3 100644 (file)
@@ -41,8 +41,8 @@ class PackageVariableTestCase(unittest.TestCase):
         assert o.key == 'test', o.key
         assert o.help == 'test option help\n    ( yes | no | /path/to/test )', repr(o.help)
         assert o.default == '/default/path', o.default
-        assert not o.validator is None, o.validator
-        assert not o.converter is None, o.converter
+        assert o.validator is not None, o.validator
+        assert o.converter is not None, o.converter
 
     def test_converter(self):
         """Test the PackageVariable converter"""
index 4e6436e98d98c36d735d78eec87f92d7d226d3e0..164325220f333fdb27c3e62d965aca580b1a3cc5 100644 (file)
@@ -44,7 +44,7 @@ class PathVariableTestCase(unittest.TestCase):
         assert o.key == 'test', o.key
         assert o.help == 'test option help ( /path/to/test )', repr(o.help)
         assert o.default == '/default/path', o.default
-        assert not o.validator is None, o.validator
+        assert o.validator is not None, o.validator
         assert o.converter is None, o.converter
 
     def test_PathExists(self):
index 69ef9fe434651fee8f7d7dc3538f3270751939ff..493d69f43c97c8701eb65214eef3ac07ac2a6921 100644 (file)
@@ -85,9 +85,9 @@ class VariablesTestCase(unittest.TestCase):
         o = opts.options[0]
         assert o.key == 'VAR'
         assert o.help == ''
-        assert o.default == None
-        assert o.validator == None
-        assert o.converter == None
+        assert o.default is None
+        assert o.validator is None
+        assert o.converter is None
 
         o = opts.options[1]
         assert o.key == 'ANSWER'
@@ -120,9 +120,9 @@ class VariablesTestCase(unittest.TestCase):
         o = opts.options[0]
         assert o.key == 'VAR2', o.key
         assert o.help == '', o.help
-        assert o.default == None, o.default
-        assert o.validator == None, o.validator
-        assert o.converter == None, o.converter
+        assert o.default is None, o.default
+        assert o.validator is None, o.validator
+        assert o.converter is None, o.converter
 
         o = opts.options[1]
         assert o.key == 'ANSWER2', o.key
index 6e188922bca04ae3dafd3f53eed1bcff55dcb7b9..eeddd873c3b9bab15a5b082f434812d2290af6ee 100644 (file)
@@ -715,7 +715,7 @@ class SConsTimer:
         lines = open(file).readlines()
         line = [ l for l in lines if l.endswith(object_string) ][0]
         result = [ int(field) for field in line.split()[:4] ]
-        if not index is None:
+        if index is not None:
             result = result[index]
         return result
 
index 0876a015528f22b4af2e7c0e0093aef04c2ec2c4..0c7c4df3dedbc2d5ae245cffddd96043cd86214b 100644 (file)
@@ -118,10 +118,10 @@ for f in files:
                 exc_all_seen = 0
                 line = l
                 #print " -> reset"
-            elif not m1 is None:
+            elif m1 is not None:
                 exc_keyboardint_seen = 1
                 #print " -> keyboard -> ", m1.groups()
-            elif not m2 is None:
+            elif m2 is not None:
                 exc_all_seen = 1
                 #print " -> all -> ", m2.groups()
             else: