Python 2 has a range() function which returns a list, and an xrange() one which returns an iterator.
Python 3 lost the function returning a list, and renamed the function returning an iterator as range(). As a result, using range() makes the scripts compatible with both Python versions 2 and 3. Signed-off-by: Mathieu Bridon <boche...@daitauha.fr> --- src/amd/vulkan/radv_entrypoints_gen.py | 2 +- src/broadcom/cle/gen_pack_header.py | 2 +- src/compiler/glsl/ir_expression_operation.py | 2 +- src/compiler/nir/nir_opcodes.py | 4 ++-- src/intel/vulkan/anv_entrypoints_gen.py | 2 +- src/mapi/glapi/gen/glX_proto_send.py | 2 +- src/mapi/glapi/gen/gl_XML.py | 2 +- src/mapi/glapi/gen/gl_gentable.py | 4 ++-- src/mapi/mapi_abi.py | 2 +- src/mesa/main/format_parser.py | 4 ++-- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/amd/vulkan/radv_entrypoints_gen.py b/src/amd/vulkan/radv_entrypoints_gen.py index 9c4dfd02a0..ca022bcbb0 100644 --- a/src/amd/vulkan/radv_entrypoints_gen.py +++ b/src/amd/vulkan/radv_entrypoints_gen.py @@ -136,7 +136,7 @@ static const struct string_map_entry string_map_entries[] = { /* Hash table stats: * size ${len(strmap.sorted_strings)} entries * collisions entries: -% for i in xrange(10): +% for i in range(10): * ${i}${'+' if i == 9 else ' '} ${strmap.collisions[i]} % endfor */ diff --git a/src/broadcom/cle/gen_pack_header.py b/src/broadcom/cle/gen_pack_header.py index c6e1c564e6..8ad54464cb 100644 --- a/src/broadcom/cle/gen_pack_header.py +++ b/src/broadcom/cle/gen_pack_header.py @@ -216,7 +216,7 @@ class Group(object): first_byte = field.start // 8 last_byte = field.end // 8 - for b in xrange(first_byte, last_byte + 1): + for b in range(first_byte, last_byte + 1): if not b in bytes: bytes[b] = self.Byte() diff --git a/src/compiler/glsl/ir_expression_operation.py b/src/compiler/glsl/ir_expression_operation.py index b3dac3da3f..16b98690a6 100644 --- a/src/compiler/glsl/ir_expression_operation.py +++ b/src/compiler/glsl/ir_expression_operation.py @@ -116,7 +116,7 @@ constant_template_common = mako.template.Template("""\ constant_template_vector_scalar = mako.template.Template("""\ case ${op.get_enum_name()}: % if "mixed" in op.flags: - % for i in xrange(op.num_operands): + % for i in range(op.num_operands): assert(op[${i}]->type->base_type == ${op.source_types[0].glsl_type} || % for src_type in op.source_types[1:-1]: op[${i}]->type->base_type == ${src_type.glsl_type} || diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py index 3c3316dcaa..b03c5da2ea 100644 --- a/src/compiler/nir/nir_opcodes.py +++ b/src/compiler/nir/nir_opcodes.py @@ -367,8 +367,8 @@ for (unsigned bit = 0; bit < bit_size; bit++) { """) -for i in xrange(1, 5): - for j in xrange(1, 5): +for i in range(1, 5): + for j in range(1, 5): unop_horiz("fnoise{0}_{1}".format(i, j), i, tfloat, j, tfloat, "0.0f") diff --git a/src/intel/vulkan/anv_entrypoints_gen.py b/src/intel/vulkan/anv_entrypoints_gen.py index 8a37336496..5e2cd0740a 100644 --- a/src/intel/vulkan/anv_entrypoints_gen.py +++ b/src/intel/vulkan/anv_entrypoints_gen.py @@ -145,7 +145,7 @@ static const struct string_map_entry string_map_entries[] = { /* Hash table stats: * size ${len(strmap.sorted_strings)} entries * collisions entries: -% for i in xrange(10): +% for i in range(10): * ${i}${'+' if i == 9 else ' '} ${strmap.collisions[i]} % endfor */ diff --git a/src/mapi/glapi/gen/glX_proto_send.py b/src/mapi/glapi/gen/glX_proto_send.py index fba2f0cc1e..a920ecc012 100644 --- a/src/mapi/glapi/gen/glX_proto_send.py +++ b/src/mapi/glapi/gen/glX_proto_send.py @@ -392,7 +392,7 @@ static const struct proc_pair _glapi_proc proc; } proc_pairs[%d] = {""" % len(procs)) names = sorted(procs.keys()) - for i in xrange(len(names)): + for i in range(len(names)): comma = ',' if i < len(names) - 1 else '' print(' { "%s", (_glapi_proc) gl%s }%s' % (names[i], procs[names[i]], comma)) print("""}; diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py index bfbb1ec6e0..96dc1b3c12 100644 --- a/src/mapi/glapi/gen/gl_XML.py +++ b/src/mapi/glapi/gen/gl_XML.py @@ -834,7 +834,7 @@ class gl_function( gl_item ): versions. """ result = [] - for entry_point, api_to_ver in self.entry_point_api_map.iteritems(): + for entry_point, api_to_ver in self.entry_point_api_map.items(): if api not in api_to_ver: continue if version is not None and version < api_to_ver[api]: diff --git a/src/mapi/glapi/gen/gl_gentable.py b/src/mapi/glapi/gen/gl_gentable.py index 49206b1167..9d8923cf8d 100644 --- a/src/mapi/glapi/gen/gl_gentable.py +++ b/src/mapi/glapi/gen/gl_gentable.py @@ -216,13 +216,13 @@ class PrintCode(gl_XML.gl_print_base): # Check that the table has no gaps. We expect a function at every offset, # and the code which generates the table relies on this. - for i in xrange(0, func_count): + for i in range(0, func_count): if funcnames[i] is None: raise Exception("Function table has no function at offset %d" % (i)) print("#define GLAPI_TABLE_COUNT %d" % func_count) print("static const char * const _glapi_table_func_names[GLAPI_TABLE_COUNT] = {") - for i in xrange(0, func_count): + for i in range(0, func_count): print(" /* %5d */ \"%s\"," % (i, funcnames[i])) print("};") diff --git a/src/mapi/mapi_abi.py b/src/mapi/mapi_abi.py index 826721479d..be1d15d922 100644 --- a/src/mapi/mapi_abi.py +++ b/src/mapi/mapi_abi.py @@ -260,7 +260,7 @@ def abi_sanity_check(entries): all_names = [] last_slot = entries[-1].slot i = 0 - for slot in xrange(last_slot + 1): + for slot in range(last_slot + 1): if entries[i].slot != slot: raise Exception('entries are not ordered by slots') if entries[i].alias: diff --git a/src/mesa/main/format_parser.py b/src/mesa/main/format_parser.py index 4c36c3cee2..3321ad33ff 100644 --- a/src/mesa/main/format_parser.py +++ b/src/mesa/main/format_parser.py @@ -216,8 +216,8 @@ class Swizzle: component, exactly as you would expect. """ rev = [Swizzle.SWIZZLE_NONE] * 4 - for i in xrange(4): - for j in xrange(4): + for i in range(4): + for j in range(4): if self.__list[j] == i and rev[i] == Swizzle.SWIZZLE_NONE: rev[i] = j return Swizzle(rev) -- 2.17.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev