diff options
author | Mathieu Bridon <[email protected]> | 2018-07-06 12:17:50 +0200 |
---|---|---|
committer | Dylan Baker <[email protected]> | 2018-07-24 11:07:04 -0700 |
commit | 01da2feb0edd36abb161d96ccd6020c4b358da91 (patch) | |
tree | 229be3cd2888fcdc4a317fcbbb44a3babaea5278 /src/mapi/glapi/gen/gl_XML.py | |
parent | 5530cb1296cef759ea2f94e581da0a4d853a9f5f (diff) |
python: Better sort dictionary keys/values
In Python 2, dict.keys() and dict.values() both return a list, which can
be sorted in two ways:
* l.sort() modifies the list in-place;
* sorted(l) returns a new, sorted list;
In Python 3, dict.keys() and dict.values() do not return lists any more,
but iterators. Iterators do not have a .sort() method.
This commit moves the build scripts to using sorted() on dict keys and
values, which makes them compatible with both Python 2 and Python 3.
Signed-off-by: Mathieu Bridon <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]>
Reviewed-by: Dylan Baker <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mapi/glapi/gen/gl_XML.py')
-rw-r--r-- | src/mapi/glapi/gen/gl_XML.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/mapi/glapi/gen/gl_XML.py b/src/mapi/glapi/gen/gl_XML.py index 20057cf9c4f..7bd5a1f4e43 100644 --- a/src/mapi/glapi/gen/gl_XML.py +++ b/src/mapi/glapi/gen/gl_XML.py @@ -988,12 +988,10 @@ class gl_api(object): functions = [] for func_cat_type in range(0,4): - keys = lists[func_cat_type].keys() - keys.sort() + keys = sorted(lists[func_cat_type].keys()) for key in keys: - names = lists[func_cat_type][key].keys() - names.sort() + names = sorted(lists[func_cat_type][key].keys()) for name in names: functions.append(lists[func_cat_type][key][name]) @@ -1027,8 +1025,7 @@ class gl_api(object): def enumIterateByName(self): - keys = self.enums_by_name.keys() - keys.sort() + keys = sorted(self.enums_by_name.keys()) list = [] for enum in keys: @@ -1047,8 +1044,7 @@ class gl_api(object): list = [] for cat_type in range(0,4): - keys = self.categories[cat_type].keys() - keys.sort() + keys = sorted(self.categories[cat_type].keys()) for key in keys: list.append(self.categories[cat_type][key]) |