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 <bochecha@daitauha.fr> Reviewed-by: Eric Engestrom <eric.engestrom@intel.com> Reviewed-by: Dylan Baker <dylan@pnwbakers.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:

committed by
Dylan Baker

parent
5530cb1296
commit
01da2feb0e
@@ -391,8 +391,7 @@ static const struct proc_pair
|
||||
const char *name;
|
||||
_glapi_proc proc;
|
||||
} proc_pairs[%d] = {""" % len(procs))
|
||||
names = procs.keys()
|
||||
names.sort()
|
||||
names = sorted(procs.keys())
|
||||
for i in xrange(len(names)):
|
||||
comma = ',' if i < len(names) - 1 else ''
|
||||
print(' { "%s", (_glapi_proc) gl%s }%s' % (names[i], procs[names[i]], comma))
|
||||
|
Reference in New Issue
Block a user