python: Explicitly use a list
authorMathieu Bridon <bochecha@daitauha.fr>
Thu, 9 Aug 2018 08:27:20 +0000 (10:27 +0200)
committerDylan Baker <dylan@pnwbakers.com>
Thu, 9 Aug 2018 23:49:18 +0000 (16:49 -0700)
On Python 2, the builtin functions filter() returns a list.

On Python 3, it returns an iterator.

Since we want to use those objects in contexts where we need lists, we
need to explicitly turn them into lists.

This makes the code compatible with both Python 2 and Python 3.

Signed-off-by: Mathieu Bridon <bochecha@daitauha.fr>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
src/mesa/main/get_hash_generator.py

index facdccd..37dae45 100644 (file)
@@ -117,8 +117,8 @@ def print_tables(tables):
 def merge_tables(tables):
    merged_tables = []
    for api, indices in sorted(tables.items()):
-      matching_table = filter(lambda mt:mt["indices"] == indices,
-                              merged_tables)
+      matching_table = list(filter(lambda mt:mt["indices"] == indices,
+                              merged_tables))
       if matching_table:
          matching_table[0]["apis"].append(api)
       else: