Commits

Anonymous committed 5cf8e81

http://scons.tigris.org/issues/show_bug.cgi?id=2345

Fix the 'assignment to True or False' and the '__getitem__ not supported for
exception classes' deprecation warnings.

Comments (0)

Files changed (16)

QMTest/TestCmd.py

             try:
                 written = os.write(self.stdin.fileno(), input)
             except OSError, why:
-                if why[0] == errno.EPIPE: #broken pipe
+                if why.args[0] == errno.EPIPE: #broken pipe
                     return self._close('stdin')
                 raise
 

QMTest/TestSCons.py

 import time
 
 try:
-    x = True
+    True
 except NameError:
-    True = not 0
-    False = not 1
-else:
-    del x
+    exec('True = not 0')
+    exec('False = not 1')
 
 from TestCommon import *
 from TestCommon import __all__

src/engine/SCons/Builder.py

         try:
             ret = SCons.Util.Selector.__call__(self, env, source, ext)
         except KeyError, e:
-            raise UserError("Ambiguous suffixes after environment substitution: %s == %s == %s" % (e[0], e[1], e[2]))
+            raise UserError("Ambiguous suffixes after environment substitution: %s == %s == %s" % (e.args[0], e.args[1], e.args[2]))
         if ret is None:
             raise UserError("While building `%s' from `%s': Don't know how to build from a source file with suffix `%s'.  Expected a suffix in this list: %s." % \
                             (repr(list(map(str, target))), repr(list(map(str, source))), ext, repr(self.keys())))

src/engine/SCons/Defaults.py

             os.makedirs(str(entry))
         except os.error, e:
             p = str(entry)
-            if (e[0] == errno.EEXIST or (sys.platform=='win32' and e[0]==183)) \
+            if (e.args[0] == errno.EEXIST or
+                    (sys.platform=='win32' and e.args[0]==183)) \
                     and os.path.isdir(str(entry)):
                 pass            # not an error if already exists
             else:

src/engine/SCons/Script/Main.py

     *current call stack* rather than sys.exc_info() to get our stack trace.
     This is used by the warnings framework to print warnings."""
     filename, lineno, routine, dummy = find_deepest_user_frame(traceback.extract_stack())
-    sys.stderr.write("\nscons: warning: %s\n" % e[0])
+    sys.stderr.write("\nscons: warning: %s\n" % e.args[0])
     sys.stderr.write('File "%s", line %d, in %s\n' % (filename, lineno, routine))
 
 def _scons_internal_error():

src/engine/SCons/WarningsTests.py

 
 class TestOutput:
     def __call__(self, x):
-        args = x[0]
+        args = x.args[0]
         if len(args) == 1:
             args = args[0]
         self.out = str(args)

src/engine/SCons/compat/_scons_builtins.py

 import builtins
 
 try:
+    False
+except NameError:
+    # Pre-2.2 Python has no False keyword.
+    exec('builtins.False = not 1')
+    # Assign to False in this module namespace so it shows up in pydoc output.
+    #False = False
+
+try:
+    True
+except NameError:
+    # Pre-2.2 Python has no True keyword.
+    exec('builtins.True = not 0')
+    # Assign to True in this module namespace so it shows up in pydoc output.
+    #True = True
+
+try:
     all
 except NameError:
     # Pre-2.5 Python has no all() function.
     builtins.dict = dict
 
 try:
-    False
-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
-
-try:
-    True
-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
-
-try:
     file
 except NameError:
     # Pre-2.2 Python has no file() function.

src/engine/SCons/compat/_scons_subprocess.py

 except:
     MAXFD = 256
 
-# True/False does not exist on 2.2.0
-try:
-    False
-except NameError:
-    False = 0
-    True = 1
-
 try:
     isinstance(1, int)
 except TypeError:

src/script/scons-time.py

 import time
 
 try:
-    False
+    True, False
 except NameError:
-    # Pre-2.2 Python has no False keyword.
-    False = not 1
-
-try:
-    True
-except NameError:
-    # Pre-2.2 Python has no True keyword.
-    True = not 0
+    # Pre-2.2 Python has no True or False keyword.
+    exec('True = not 0')
+    exec('False = not 1')
 
 try:
     sorted

test/Deprecated/Options/BoolOption.py

 try:
     True, False
 except NameError:
-    True = (0 == 0)
-    False = (0 != 0)
+    exec('True = (0 == 0)')
+    exec('False = (0 != 0)')
 
 import TestSCons
 

test/Deprecated/Options/PackageOption.py

 try:
     True, False
 except NameError:
-    True = (0 == 0)
-    False = (0 != 0)
+    exec('True = (0 == 0)')
+    exec('False = (0 != 0)')
 
 import TestSCons
 

test/Deprecated/Options/help.py

 try:
     True, False
 except NameError:
-    True = (0 == 0)
-    False = (0 != 0)
+    exec('True = (0 == 0)')
+    exec('False = (0 != 0)')
 
 str_True = str(True)
 str_False = str(False)
 import os
 Import('*')
 
-import __builtin__
-try:
-    __builtin__.True
-except AttributeError:
-    __builtin__.True = 1
-    __builtin__.False = 0
-
 def mycopy(env, source, target):
     open(str(target[0]),'w').write(open(str(source[0]),'r').read())
 

test/Variables/BoolVariable.py

 try:
     True, False
 except NameError:
-    True = (0 == 0)
-    False = (0 != 0)
+    exec('True = (0 == 0)')
+    exec('False = (0 != 0)')
 
 import TestSCons
 

test/Variables/PackageVariable.py

 try:
     True, False
 except NameError:
-    True = (0 == 0)
-    False = (0 != 0)
+    exec('True = (0 == 0)')
+    exec('False = (0 != 0)')
 
 import TestSCons
 

test/Variables/help.py

 try:
     True, False
 except NameError:
-    True = (0 == 0)
-    False = (0 != 0)
+    exec('True = (0 == 0)')
+    exec('False = (0 != 0)')
 
 str_True = str(True)
 str_False = str(False)