From 2a0f4e1c0adbd29ad06075d5e8f3e07dfd548d51 Mon Sep 17 00:00:00 2001 From: gregnoel Date: Mon, 29 Mar 2010 14:21:04 +0000 Subject: [PATCH] http://scons.tigris.org/issues/show_bug.cgi?id=2345 The 'buffer' fixer simply replaces 'buffer( ... )' with 'memoryview( ... )', which is incorrect for our cases, so these changes had to be done by hand and a forward-compatibility class added. The 'xrange' fixer was applied. Manual changes were minimal: a few case in test strings and one use of 'range' as an identifer in the same scope as where 'xrange' was converted to 'range'. The "sets15" compat function, which provided backward compatibility for Python versions prior to 2.2, was removed as no longer needed. git-svn-id: http://scons.tigris.org/svn/scons/trunk@4735 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- QMTest/TestCmd.py | 18 +- src/engine/SCons/ActionTests.py | 1 - src/engine/SCons/Script/Main.py | 2 +- src/engine/SCons/compat/__init__.py | 32 ++-- src/engine/SCons/compat/_scons_sets.py | 3 +- src/engine/SCons/compat/_scons_sets15.py | 174 ------------------- src/engine/SCons/compat/_scons_subprocess.py | 14 +- src/engine/SCons/compat/builtins.py | 4 +- src/engine/SCons/dblite.py | 3 +- src/script/scons-time.py | 7 +- src/script/sconsign.py | 2 +- test/Batch/action-changed.py | 2 +- test/KeyboardInterrupt.py | 2 +- test/SWIG/build-dir.py | 2 +- test/option/md5-chunksize.py | 4 +- test/scons-time/func/chdir.py | 2 +- test/scons-time/func/glob.py | 2 +- test/scons-time/func/prefix.py | 4 +- test/scons-time/func/tail.py | 2 +- test/scons-time/mem/chdir.py | 2 +- test/scons-time/mem/glob.py | 2 +- test/scons-time/mem/prefix.py | 2 +- test/scons-time/mem/tail.py | 2 +- test/scons-time/obj/chdir.py | 2 +- test/scons-time/obj/glob.py | 2 +- test/scons-time/obj/prefix.py | 2 +- test/scons-time/obj/tail.py | 2 +- test/scons-time/time/chdir.py | 2 +- test/scons-time/time/empty.py | 2 +- test/scons-time/time/glob.py | 2 +- test/scons-time/time/no-result.py | 2 +- test/scons-time/time/prefix.py | 2 +- test/scons-time/time/tail.py | 2 +- timings/CPPPATH/SConstruct | 2 +- timings/CPPPATH/TimeSCons-run.py | 2 +- timings/hundred/SConstruct | 4 +- timings/hundred/TimeSCons-run.py | 2 +- 37 files changed, 79 insertions(+), 239 deletions(-) delete mode 100644 src/engine/SCons/compat/_scons_sets15.py diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index a7f97d7a..0139b297 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -231,6 +231,21 @@ import time import traceback import UserList +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] + __all__ = [ 'diff_re', 'fail_test', @@ -809,13 +824,12 @@ def recv_some(p, t=.1, e=1, tr=5, stderr=0): time.sleep(max((x-time.time())/tr, 0)) return ''.join(y) -# TODO(3.0: rewrite to use memoryview() def send_all(p, data): while len(data): sent = p.send(data) if sent is None: raise Exception(disconnect_message) - data = buffer(data, sent) + data = memoryview(data)[sent:] diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 052582bd..3f78812e 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 55ac5982..9b8c94b6 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 49c317c0..792b77a0 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 713d6e99..765867b0 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 b693f786..00000000 --- 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 67eafcaf..bdcae637 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 678ef2ed..4f7e7105 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 2383f1df..0789396a 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 diff --git a/src/script/scons-time.py b/src/script/scons-time.py index 04fa5730..6c43e29d 100644 --- a/src/script/scons-time.py +++ b/src/script/scons-time.py @@ -261,10 +261,9 @@ class Gnuplotter(Plotter): min_y = self.get_min_y() max_y = self.max_graph_value(self.get_max_y()) - range = max_y - min_y - incr = range / 10.0 + incr = (max_y - min_y) / 10.0 start = min_y + (max_y / 2.0) + (2.0 * incr) - position = [ start - (i * incr) for i in xrange(5) ] + position = [ start - (i * incr) for i in range(5) ] inx = 1 for line in self.lines: @@ -1268,7 +1267,7 @@ class SConsTimer: except ValueError: result.append(int(n)) else: - result.extend(range(int(x), int(y)+1)) + result.extend(list(range(int(x), int(y)+1))) return result def scons_path(self, dir): diff --git a/src/script/sconsign.py b/src/script/sconsign.py index ac619a58..e119a51f 100644 --- a/src/script/sconsign.py +++ b/src/script/sconsign.py @@ -249,7 +249,7 @@ def map_bkids(entry, name): except AttributeError: return None result = [] - for i in xrange(len(bkids)): + for i in range(len(bkids)): result.append(nodeinfo_string(bkids[i], bkidsigs[i], " ")) if result == []: return None diff --git a/test/Batch/action-changed.py b/test/Batch/action-changed.py index 886a6921..dc2805a4 100644 --- a/test/Batch/action-changed.py +++ b/test/Batch/action-changed.py @@ -43,7 +43,7 @@ import sys sep = sys.argv.index('--') targets = sys.argv[1:sep] sources = sys.argv[sep+1:] -for i in xrange(len(targets)): +for i in range(len(targets)): t = targets[i] s = sources[i] fp = open(t, 'wb') diff --git a/test/KeyboardInterrupt.py b/test/KeyboardInterrupt.py index d0f12076..bcb576c8 100644 --- a/test/KeyboardInterrupt.py +++ b/test/KeyboardInterrupt.py @@ -76,7 +76,7 @@ else: all = [] -for i in xrange(40): +for i in range(40): all.extend(Object('toto%5d' % i, 'toto.c')) all.extend(Command( 'broken', 'toto.c', explode)) diff --git a/test/SWIG/build-dir.py b/test/SWIG/build-dir.py index d5b52360..a9d7cb27 100644 --- a/test/SWIG/build-dir.py +++ b/test/SWIG/build-dir.py @@ -136,7 +136,7 @@ public: %pythoncode %{ def __iter__(self): - for i in xrange(len(self)): + for i in range(len(self)): yield self[i] %} } diff --git a/test/option/md5-chunksize.py b/test/option/md5-chunksize.py index acd34922..375208d9 100644 --- a/test/option/md5-chunksize.py +++ b/test/option/md5-chunksize.py @@ -47,8 +47,8 @@ f2 = env.B(target = 'f2.out', source = 'f2.in') Requires(f2, f1) """ % locals()) -test.write('f1.in', str(range(10))) -test.write('f2.in', str(range(100000))) +test.write('f1.in', str(list(range(10)))) +test.write('f2.in', str(list(range(100000)))) expected_stdout = test.wrap_stdout("""\ %(_python_)s build.py f1.out f1.in diff --git a/test/scons-time/func/chdir.py b/test/scons-time/func/chdir.py index 0ce43404..1aea7ade 100644 --- a/test/scons-time/func/chdir.py +++ b/test/scons-time/func/chdir.py @@ -48,7 +48,7 @@ def _main(): """ expect = [] -for i in xrange(9): +for i in range(9): i = str(i) test.subdir(i) test.profile_data('profs/foo-%s.prof' % i, '%s/prof.py' % i, '_main', input) diff --git a/test/scons-time/func/glob.py b/test/scons-time/func/glob.py index d3fd960d..62404044 100644 --- a/test/scons-time/func/glob.py +++ b/test/scons-time/func/glob.py @@ -43,7 +43,7 @@ def _main(): """ expect = [] -for i in xrange(9): +for i in range(9): test.subdir(str(i)) test.profile_data('foo-%s.prof' % i, '%s/prof.py' % i, '_main', input) expect.append((r'\d.\d\d\d %s/prof\.py:1\(_main\)' + '\n') % i) diff --git a/test/scons-time/func/prefix.py b/test/scons-time/func/prefix.py index fe3618f7..67a0c6ba 100644 --- a/test/scons-time/func/prefix.py +++ b/test/scons-time/func/prefix.py @@ -47,11 +47,11 @@ def _main(): foo_lines = [] bar_lines = [] -for i in xrange(2): +for i in range(2): test.profile_data('foo-%s.prof' % i, 'prof.py', '_main', input) foo_lines.append(r'\d.\d\d\d prof\.py:1\(_main\)' + '\n') -for i in xrange(4): +for i in range(4): test.profile_data('bar-%s.prof' % i, 'prof.py', '_main', input) bar_lines.append(r'\d.\d\d\d prof\.py:1\(_main\)' + '\n') diff --git a/test/scons-time/func/tail.py b/test/scons-time/func/tail.py index 91fa6c80..afd3f839 100644 --- a/test/scons-time/func/tail.py +++ b/test/scons-time/func/tail.py @@ -44,7 +44,7 @@ def _main(): """ expect = [] -for i in xrange(9): +for i in range(9): test.subdir(str(i)) test.profile_data('foo-%s.prof' % i, '%s/prof.py' % i, '_main', input) expect.append((r'\d.\d\d\d %s/prof\.py:1\(_main\)' + '\n') % i) diff --git a/test/scons-time/mem/chdir.py b/test/scons-time/mem/chdir.py index 52dbd2cb..5bf618c7 100644 --- a/test/scons-time/mem/chdir.py +++ b/test/scons-time/mem/chdir.py @@ -43,7 +43,7 @@ lines = [ line_fmt = ' 1000 2000 3000 4000 %s\n' -for i in xrange(9): +for i in range(9): logfile_name = os.path.join('logs', 'foo-%s.log' % i) test.fake_logfile(logfile_name) lines.append(line_fmt % logfile_name) diff --git a/test/scons-time/mem/glob.py b/test/scons-time/mem/glob.py index 04d8b095..820021e7 100644 --- a/test/scons-time/mem/glob.py +++ b/test/scons-time/mem/glob.py @@ -38,7 +38,7 @@ lines = [ line_fmt = ' 1000 2000 3000 4000 %s\n' -for i in xrange(9): +for i in range(9): logfile_name = 'foo-%s.log' % i test.fake_logfile(logfile_name) lines.append(line_fmt % logfile_name) diff --git a/test/scons-time/mem/prefix.py b/test/scons-time/mem/prefix.py index 5e64dad4..faca54da 100644 --- a/test/scons-time/mem/prefix.py +++ b/test/scons-time/mem/prefix.py @@ -43,7 +43,7 @@ line_fmt = ' 1000 2000 3000 4000 %s\n' foo_lines = [ header ] bar_lines = [ header ] -for i in xrange(3): +for i in range(3): logfile_name = os.path.join('foo-%s.log' % i) test.fake_logfile(logfile_name) foo_lines.append(line_fmt % logfile_name) diff --git a/test/scons-time/mem/tail.py b/test/scons-time/mem/tail.py index 19f4036d..cd002740 100644 --- a/test/scons-time/mem/tail.py +++ b/test/scons-time/mem/tail.py @@ -40,7 +40,7 @@ lines = [] line_fmt = ' 1000 2000 3000 4000 %s\n' -for i in xrange(9): +for i in range(9): logfile_name = 'foo-%s.log' % i test.fake_logfile(logfile_name) lines.append(line_fmt % logfile_name) diff --git a/test/scons-time/obj/chdir.py b/test/scons-time/obj/chdir.py index 5b7fe228..4b77f8ab 100644 --- a/test/scons-time/obj/chdir.py +++ b/test/scons-time/obj/chdir.py @@ -43,7 +43,7 @@ lines = [ line_fmt = ' 1101%(i)s 1102%(i)s 1103%(i)s 1104%(i)s %(logfile_name)s\n' -for i in xrange(9): +for i in range(9): logfile_name = os.path.join('logs', 'foo-%s.log' % i) test.fake_logfile(logfile_name, i) lines.append(line_fmt % locals()) diff --git a/test/scons-time/obj/glob.py b/test/scons-time/obj/glob.py index 07ccccc3..2105355a 100644 --- a/test/scons-time/obj/glob.py +++ b/test/scons-time/obj/glob.py @@ -38,7 +38,7 @@ lines = [ line_fmt = ' 601%(i)s 602%(i)s 603%(i)s 604%(i)s %(logfile_name)s\n' -for i in xrange(9): +for i in range(9): logfile_name = 'foo-%s.log' % i test.fake_logfile(logfile_name, i) lines.append(line_fmt % locals()) diff --git a/test/scons-time/obj/prefix.py b/test/scons-time/obj/prefix.py index e669cf28..0bee5f70 100644 --- a/test/scons-time/obj/prefix.py +++ b/test/scons-time/obj/prefix.py @@ -43,7 +43,7 @@ line_fmt = ' 11010 11020 11030 11040 %s\n' foo_lines = [ header ] bar_lines = [ header ] -for i in xrange(3): +for i in range(3): logfile_name = os.path.join('foo-%s.log' % i) test.fake_logfile(logfile_name) foo_lines.append(line_fmt % logfile_name) diff --git a/test/scons-time/obj/tail.py b/test/scons-time/obj/tail.py index 9049c89c..341a905f 100644 --- a/test/scons-time/obj/tail.py +++ b/test/scons-time/obj/tail.py @@ -40,7 +40,7 @@ lines = [] line_fmt = ' 1501%(i)s 1502%(i)s 1503%(i)s 1504%(i)s %(logfile_name)s\n' -for i in xrange(9): +for i in range(9): logfile_name = 'foo-%s.log' % i test.fake_logfile(logfile_name, i) lines.append(line_fmt % locals()) diff --git a/test/scons-time/time/chdir.py b/test/scons-time/time/chdir.py index ef340a10..762de759 100644 --- a/test/scons-time/time/chdir.py +++ b/test/scons-time/time/chdir.py @@ -43,7 +43,7 @@ lines = [ line_fmt = ' 11.123456 22.234567 33.345678 44.456789 %s\n' -for i in xrange(9): +for i in range(9): logfile_name = os.path.join('logs', 'foo-%s.log' % i) test.fake_logfile(logfile_name) lines.append(line_fmt % logfile_name) diff --git a/test/scons-time/time/empty.py b/test/scons-time/time/empty.py index d73db79d..a59a014c 100644 --- a/test/scons-time/time/empty.py +++ b/test/scons-time/time/empty.py @@ -41,7 +41,7 @@ lines = [] line_fmt = ' 11.123456 22.234567 33.345678 44.456789 %s\n' empty_fmt = ' %s\n' -for i in xrange(9): +for i in range(9): logfile_name = 'foo-%s-0.log' % i if i == 5: test.write(test.workpath(logfile_name), "") diff --git a/test/scons-time/time/glob.py b/test/scons-time/time/glob.py index d202e612..1a76d9fc 100644 --- a/test/scons-time/time/glob.py +++ b/test/scons-time/time/glob.py @@ -38,7 +38,7 @@ lines = [ line_fmt = ' 11.123456 22.234567 33.345678 44.456789 %s\n' -for i in xrange(9): +for i in range(9): logfile_name = 'foo-%s.log' % i test.fake_logfile(logfile_name) lines.append(line_fmt % logfile_name) diff --git a/test/scons-time/time/no-result.py b/test/scons-time/time/no-result.py index baf06d77..fbd2de92 100644 --- a/test/scons-time/time/no-result.py +++ b/test/scons-time/time/no-result.py @@ -49,7 +49,7 @@ line_fmt = "%s 11.123456\n" lines = [] -for i in xrange(9): +for i in range(9): logfile_name = 'foo-%s-0.log' % i if i == 5: test.write(test.workpath(logfile_name), "NO RESULTS HERE!\n") diff --git a/test/scons-time/time/prefix.py b/test/scons-time/time/prefix.py index d12287d5..00a1f52e 100644 --- a/test/scons-time/time/prefix.py +++ b/test/scons-time/time/prefix.py @@ -43,7 +43,7 @@ line_fmt = ' 11.123456 22.234567 33.345678 44.456789 %s\n' foo_lines = [ header ] bar_lines = [ header ] -for i in xrange(3): +for i in range(3): logfile_name = os.path.join('foo-%s.log' % i) test.fake_logfile(logfile_name) foo_lines.append(line_fmt % logfile_name) diff --git a/test/scons-time/time/tail.py b/test/scons-time/time/tail.py index 372f7852..c89f9046 100644 --- a/test/scons-time/time/tail.py +++ b/test/scons-time/time/tail.py @@ -40,7 +40,7 @@ lines = [] line_fmt = ' 11.123456 22.234567 33.345678 44.456789 %s\n' -for i in xrange(9): +for i in range(9): logfile_name = 'foo-%s.log' % i test.fake_logfile(logfile_name) lines.append(line_fmt % logfile_name) diff --git a/timings/CPPPATH/SConstruct b/timings/CPPPATH/SConstruct index d49e3d63..14cc7692 100644 --- a/timings/CPPPATH/SConstruct +++ b/timings/CPPPATH/SConstruct @@ -23,7 +23,7 @@ dir_count = int(ARGUMENTS['DIR_COUNT']) -inc_list = [ Dir('inc_%04d' % t) for t in xrange(dir_count) ] +inc_list = [ Dir('inc_%04d' % t) for t in range(dir_count) ] inc_list.append(Dir('include')) env = Environment(CPPPATH = inc_list) diff --git a/timings/CPPPATH/TimeSCons-run.py b/timings/CPPPATH/TimeSCons-run.py index 97d9e053..b26fafcf 100644 --- a/timings/CPPPATH/TimeSCons-run.py +++ b/timings/CPPPATH/TimeSCons-run.py @@ -47,7 +47,7 @@ import TestSCons test = TestSCons.TimeSCons(variables={'DIR_COUNT':813}) -for d in xrange(test.variables['DIR_COUNT']): +for d in range(test.variables['DIR_COUNT']): test.subdir('inc_%04d' % d) test.main() diff --git a/timings/hundred/SConstruct b/timings/hundred/SConstruct index c824b887..b321d108 100644 --- a/timings/hundred/SConstruct +++ b/timings/hundred/SConstruct @@ -27,8 +27,8 @@ def copy_files( env, target, source ): for t, s in zip(target, source): open(str(t), 'wb').write(open(str(s), 'rb').read()) -source_list = ['source_%04d' % t for t in xrange(target_count)] -target_list = ['target_%04d' % t for t in xrange(target_count)] +source_list = ['source_%04d' % t for t in range(target_count)] +target_list = ['target_%04d' % t for t in range(target_count)] env = Environment() diff --git a/timings/hundred/TimeSCons-run.py b/timings/hundred/TimeSCons-run.py index c90c26b9..3d5b02f9 100644 --- a/timings/hundred/TimeSCons-run.py +++ b/timings/hundred/TimeSCons-run.py @@ -46,7 +46,7 @@ import TestSCons test = TestSCons.TimeSCons(variables={'TARGET_COUNT':139}) -for t in xrange(test.variables['TARGET_COUNT']): +for t in range(test.variables['TARGET_COUNT']): open('source_%04d' % t, 'wb' ).write('contents\n') test.main() -- 2.26.2