Commits

anatoly techtonik committed c8c9cef

Removed some pre-Python 2.4 compatibility code

  • Participants
  • Parent commits 0183798

Comments (0)

Files changed (4)

QMTest/TestSCons_time.py

 
         TestCommon.__init__(self, **kw)
 
-        # Now that the testing object has been set up, check if we should
-        # skip the test due to the Python version.  We need to be able to
-        # import __future__ (which scons-time.py uses for nested scopes)
-        # and to handle list comprehensions (just because we're avoiding
-        # the old map() and filter() idioms).
-
-        try:
-            import __future__
-        except ImportError:
-            version = sys.version.split()[0]
-            msg = 'scons-time does not work on Python version %s\n' % version
-            self.skip_test(msg)
-
-        try:
-            eval('[x for x in [1, 2]]')
-        except SyntaxError:
-            version = sys.version.split()[0]
-            msg = 'scons-time does not work on Python version %s\n' % version
-            self.skip_test(msg)
-
     def archive_split(self, path):
         if path[-7:] == '.tar.gz':
             return path[:-7], path[-7:]

src/engine/SCons/Script/SConscript.py

 
     def EnsurePythonVersion(self, major, minor):
         """Exit abnormally if the Python version is not late enough."""
-        try:
-            v_major, v_minor, v_micro, release, serial = sys.version_info
-            python_ver = (v_major, v_minor)
-        except AttributeError:
-            python_ver = self._get_major_minor_revision(sys.version)[:2]
-        if python_ver < (major, minor):
-            v = sys.version.split(" ", 1)[0]
+        if sys.version_info < (major, minor):
+            v = sys.version.split()[0]
             print "Python %d.%d or greater required, but you have Python %s" %(major,minor,v)
             sys.exit(2)
 

src/engine/SCons/compat/_scons_builtins.py

 
         all()
         any()
-        sorted()
         memoryview()
 
 Implementations of functions are *NOT* guaranteed to be fully compliant
                 return self.obj[indx]
     builtins.memoryview = memoryview
 
-try:
-    sorted
-except NameError:
-    # Pre-2.4 Python has no sorted() function.
-    #
-    # The pre-2.4 Python list.sort() method does not support
-    # list.sort(key=) nor list.sort(reverse=) keyword arguments, so
-    # we must implement the functionality of those keyword arguments
-    # by hand instead of passing them to list.sort().
-    def sorted(iterable, cmp=None, key=None, reverse=False):
-        if key is not None:
-            result = [(key(x), x) for x in iterable]
-        else:
-            result = iterable[:]
-        if cmp is None:
-            # Pre-2.3 Python does not support list.sort(None).
-            result.sort()
-        else:
-            result.sort(cmp)
-        if key is not None:
-            result = [t1 for t0,t1 in result]
-        if reverse:
-            result.reverse()
-        return result
-    builtins.sorted = sorted
-
-#if sys.version_info[:3] in ((2, 2, 0), (2, 2, 1)):
-#    def lstrip(s, c=string.whitespace):
-#        while s and s[0] in c:
-#            s = s[1:]
-#        return s
-#    def rstrip(s, c=string.whitespace):
-#        while s and s[-1] in c:
-#            s = s[:-1]
-#        return s
-#    def strip(s, c=string.whitespace, l=lstrip, r=rstrip):
-#        return l(r(s, c), c)
-#
-#    object.__setattr__(str, 'lstrip', lstrip)
-#    object.__setattr__(str, 'rstrip', rstrip)
-#    object.__setattr__(str, 'strip', strip)
-
 # Local Variables:
 # tab-width:4
 # indent-tabs-mode:nil

src/script/scons.py

 # engine modules if they're in either directory.
 
 
-# Check to see if the python version is > 3.0 which is currently unsupported
-# If so exit with error message
-try:
-    if  sys.version_info >= (3,0,0):
-        msg = "scons: *** SCons version %s does not run under Python version %s.\n\
-Python 3.0 and later are not yet supported.\n"
-        sys.stderr.write(msg % (__version__, sys.version.split()[0]))
-        sys.exit(1)
-except AttributeError:
-    # Pre-1.6 Python has no sys.version_info
-    # No need to check version as we then know the version is < 3.0.0 and supported
-    pass
+if sys.version_info >= (3,0,0):
+    msg = "scons: *** SCons version %s does not run under Python version %s.\n\
+Python 3 is not yet supported.\n"
+    sys.stderr.write(msg % (__version__, sys.version.split()[0]))
+    sys.exit(1)
+
 
 script_dir = sys.path[0]