summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons')
-rw-r--r--src/engine/SCons/ActionTests.py1
-rw-r--r--src/engine/SCons/Script/Main.py2
-rw-r--r--src/engine/SCons/compat/__init__.py32
-rw-r--r--src/engine/SCons/compat/_scons_sets.py3
-rw-r--r--src/engine/SCons/compat/_scons_sets15.py174
-rw-r--r--src/engine/SCons/compat/_scons_subprocess.py14
-rw-r--r--src/engine/SCons/compat/builtins.py4
-rw-r--r--src/engine/SCons/dblite.py3
8 files changed, 30 insertions, 203 deletions
diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py
index 052582b..3f78812 100644
--- a/src/engine/SCons/ActionTests.py
+++ b/src/engine/SCons/ActionTests.py
@@ -191,7 +191,6 @@ _null = SCons.Action._null
def test_varlist(pos_call, str_call, cmd, cmdstrfunc, **kw):
def call_action(a, pos_call=pos_call, str_call=str_call, kw=kw):
- #FUTURE a = SCons.Action.Action(*a, **kw)
a = SCons.Action.Action(*a, **kw)
# returned object must provide these entry points
assert hasattr(a, '__call__')
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py
index 55ac598..9b8c94b 100644
--- a/src/engine/SCons/Script/Main.py
+++ b/src/engine/SCons/Script/Main.py
@@ -1148,7 +1148,7 @@ def _build_targets(fs, options, targets, target_top):
# This is cribbed from the implementation of
# random.shuffle() in Python 2.X.
d = dependencies
- for i in xrange(len(d)-1, 0, -1):
+ for i in range(len(d)-1, 0, -1):
j = int(random.random() * (i+1))
d[i], d[j] = d[j], d[i]
return d
diff --git a/src/engine/SCons/compat/__init__.py b/src/engine/SCons/compat/__init__.py
index 49c317c..792b77a 100644
--- a/src/engine/SCons/compat/__init__.py
+++ b/src/engine/SCons/compat/__init__.py
@@ -92,19 +92,8 @@ try:
set
except NameError:
# Pre-2.4 Python has no native set type
- try:
- # Python 2.2 and 2.3 can use the copy of the 2.[45] sets module
- # that we grabbed.
- import_as('_scons_sets', 'sets')
- except (ImportError, SyntaxError):
- # Python 1.5 (ImportError, no __future_ module) and 2.1
- # (SyntaxError, no generators in __future__) will blow up
- # trying to import the 2.[45] sets module, so back off to a
- # custom sets module that can be discarded easily when we
- # stop supporting those versions.
- import_as('_scons_sets15', 'sets')
- import __builtin__
- import sets
+ import_as('_scons_sets', 'sets')
+ import __builtin__, sets
__builtin__.set = sets.Set
import fnmatch
@@ -312,7 +301,22 @@ except AttributeError:
tempfile.mkstemp = mkstemp
del mkstemp
-
+try:
+ # pre-2.7 doesn't have the memoryview() built-in
+ memoryview
+except NameError:
+ class memoryview:
+ from types import SliceType
+ def __init__(self, obj):
+ # wrapping buffer in () keeps the fixer from changing it
+ self.obj = (buffer)(obj)
+ def __getitem__(self, indx):
+ if isinstance(indx, self.SliceType):
+ return self.obj[indx.start:indx.stop]
+ else:
+ return self.obj[indx]
+ import __builtin__
+ __builtin__.memoryview = memoryview
# Local Variables:
diff --git a/src/engine/SCons/compat/_scons_sets.py b/src/engine/SCons/compat/_scons_sets.py
index 713d6e9..765867b 100644
--- a/src/engine/SCons/compat/_scons_sets.py
+++ b/src/engine/SCons/compat/_scons_sets.py
@@ -121,7 +121,8 @@ class BaseSet(object):
This is the keys iterator for the underlying dict.
"""
- return self._data.iterkeys()
+ # Wrapping name in () prevents fixer from "fixing" this
+ return (self._data.iterkeys)()
# Three-way comparison is not supported. However, because __eq__ is
# tried before __cmp__, if Set x == Set y, x.__eq__(y) returns True and
diff --git a/src/engine/SCons/compat/_scons_sets15.py b/src/engine/SCons/compat/_scons_sets15.py
deleted file mode 100644
index b693f78..0000000
--- a/src/engine/SCons/compat/_scons_sets15.py
+++ /dev/null
@@ -1,174 +0,0 @@
-#
-# A Set class that works all the way back to Python 1.5. From:
-#
-# Python Cookbook: Yet another Set class for Python
-# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/106469
-# Goncalo Rodriques
-#
-# This is a pure Pythonic implementation of a set class. The syntax
-# and methods implemented are, for the most part, borrowed from
-# PEP 218 by Greg Wilson.
-#
-# Note that this class violates the formal definition of a set() by adding
-# a __getitem__() method so we can iterate over a set's elements under
-# Python 1.5 and 2.1, which don't support __iter__() and iterator types.
-#
-
-class Set:
- """The set class. It can contain mutable objects."""
-
- def __init__(self, seq = None):
- """The constructor. It can take any object giving an iterator as an optional
- argument to populate the new set."""
- self.elems = []
- if seq:
- for elem in seq:
- if elem not in self.elems:
- hash(elem)
- self.elems.append(elem)
-
- def __str__(self):
- return "set([%s])" % ", ".join(map(str, self.elems))
-
-
- def copy(self):
- """Shallow copy of a set object."""
- return Set(self.elems)
-
- def __contains__(self, elem):
- return elem in self.elems
-
- def __len__(self):
- return len(self.elems)
-
- def __getitem__(self, index):
- # Added so that Python 1.5 can iterate over the elements.
- # The cookbook recipe's author didn't like this because there
- # really isn't any order in a set object, but this is necessary
- # to make the class work well enough for our purposes.
- return self.elems[index]
-
- def items(self):
- """Returns a list of the elements in the set."""
- return self.elems
-
- def add(self, elem):
- """Add one element to the set."""
- if elem not in self.elems:
- hash(elem)
- self.elems.append(elem)
-
- def remove(self, elem):
- """Remove an element from the set. Return an error if elem is not in the set."""
- try:
- self.elems.remove(elem)
- except ValueError:
- raise LookupError, "Object %s is not a member of the set." % str(elem)
-
- def discard(self, elem):
- """Remove an element from the set. Do nothing if elem is not in the set."""
- try:
- self.elems.remove(elem)
- except ValueError:
- pass
-
- def sort(self, func=cmp):
- self.elems.sort(func)
-
- #Define an iterator for a set.
- def __iter__(self):
- return iter(self.elems)
-
- #The basic binary operations with sets.
- def __or__(self, other):
- """Union of two sets."""
- ret = self.copy()
- for elem in other.elems:
- if elem not in ret:
- ret.elems.append(elem)
- return ret
-
- def __sub__(self, other):
- """Difference of two sets."""
- ret = self.copy()
- for elem in other.elems:
- ret.discard(elem)
- return ret
-
- def __and__(self, other):
- """Intersection of two sets."""
- ret = Set()
- for elem in self.elems:
- if elem in other.elems:
- ret.elems.append(elem)
- return ret
-
- def __add__(self, other):
- """Symmetric difference of two sets."""
- ret = Set()
- temp = other.copy()
- for elem in self.elems:
- if elem in temp.elems:
- temp.elems.remove(elem)
- else:
- ret.elems.append(elem)
- #Add remaining elements.
- for elem in temp.elems:
- ret.elems.append(elem)
- return ret
-
- def __mul__(self, other):
- """Cartesian product of two sets."""
- ret = Set()
- for elemself in self.elems:
- x = list(map(lambda other, s=elemself: (s, other), other.elems))
- ret.elems.extend(x)
- return ret
-
- #Some of the binary comparisons.
- def __lt__(self, other):
- """Returns 1 if the lhs set is contained but not equal to the rhs set."""
- if len(self.elems) < len(other.elems):
- temp = other.copy()
- for elem in self.elems:
- if elem in temp.elems:
- temp.remove(elem)
- else:
- return 0
- return len(temp.elems) == 0
- else:
- return 0
-
- def __le__(self, other):
- """Returns 1 if the lhs set is contained in the rhs set."""
- if len(self.elems) <= len(other.elems):
- ret = 1
- for elem in self.elems:
- if elem not in other.elems:
- ret = 0
- break
- return ret
- else:
- return 0
-
- def __eq__(self, other):
- """Returns 1 if the sets are equal."""
- if len(self.elems) != len(other.elems):
- return 0
- else:
- return len(self - other) == 0
-
- def __cmp__(self, other):
- """Returns 1 if the sets are equal."""
- if self.__lt__(other):
- return -1
- elif other.__lt__(self):
- return 1
- else:
- return 0
-
-# Local Variables:
-# tab-width:4
-# indent-tabs-mode:nil
-# End:
-# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/src/engine/SCons/compat/_scons_subprocess.py b/src/engine/SCons/compat/_scons_subprocess.py
index 67eafca..bdcae63 100644
--- a/src/engine/SCons/compat/_scons_subprocess.py
+++ b/src/engine/SCons/compat/_scons_subprocess.py
@@ -458,13 +458,10 @@ try:
except AttributeError:
try:
types.StringTypes = (str, unicode)
- except AttributeError:
+ except NameError:
types.StringTypes = (str,)
- def is_string(obj):
- return type(obj) in types.StringTypes
-else:
- def is_string(obj):
- return isinstance(obj, types.StringTypes)
+def is_string(obj):
+ return isinstance(obj, types.StringTypes)
_active = []
@@ -1002,7 +999,7 @@ class Popen(object):
def _close_fds(self, but):
- for i in xrange(3, MAXFD):
+ for i in range(3, MAXFD):
if i == but:
continue
try:
@@ -1186,7 +1183,8 @@ class Popen(object):
# When select has indicated that the file is writable,
# we can write up to PIPE_BUF bytes without risk
# blocking. POSIX defines PIPE_BUF >= 512
- bytes_written = os.write(self.stdin.fileno(), buffer(input, input_offset, 512))
+ m = memoryview(input)[input_offset:input_offset+512]
+ bytes_written = os.write(self.stdin.fileno(), m)
input_offset = input_offset + bytes_written
if input_offset >= len(input):
self.stdin.close()
diff --git a/src/engine/SCons/compat/builtins.py b/src/engine/SCons/compat/builtins.py
index 678ef2e..4f7e710 100644
--- a/src/engine/SCons/compat/builtins.py
+++ b/src/engine/SCons/compat/builtins.py
@@ -184,13 +184,11 @@ except NameError:
argument sequence.
"""
result = []
- for i in xrange(min(list(map(len, lists)))):
+ for i in range(min(list(map(len, lists)))):
result.append(tuple([l[i] for l in lists]))
return result
__builtin__.zip = zip
-
-
#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:
diff --git a/src/engine/SCons/dblite.py b/src/engine/SCons/dblite.py
index 2383f1d..0789396 100644
--- a/src/engine/SCons/dblite.py
+++ b/src/engine/SCons/dblite.py
@@ -157,7 +157,8 @@ class dblite:
return key in self._dict
def iterkeys(self):
- return self._dict.iterkeys()
+ # Wrapping name in () prevents fixer from "fixing" this
+ return (self._dict.iterkeys)()
__iter__ = iterkeys