tools/xen-foreign: Update python scripts to be Py3 compatible
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 11 Mar 2019 19:18:40 +0000 (19:18 +0000)
committerWei Liu <wei.liu2@citrix.com>
Tue, 12 Mar 2019 12:57:21 +0000 (12:57 +0000)
commita9047a722ba5de38e7c1d762ffcfb74c36725fe2
treec19af7eddd01f279791da7e8d8c571d3c14a3902
parent66b4a510b77588570b1fa6a2110c9293d511d0fe
tools/xen-foreign: Update python scripts to be Py3 compatible

The issues are:
 * dict.has_key() was completely removed in Py3
 * dict.keys() is an iterable rather than list in Py3, so .sort() doesn't work.
 * list.sort(cmp=) was deprecated in Py2.4 and removed in Py3.

The has_key() issue is trivially fixed by switching to using the in keyword.
The sorting issue could be trivially fixed, but take the opportunity to
improve the code.

The reason for the sorting is to ensure that "unsigned long" gets replaced
before "long", and the only reason sorting is necessary is because
inttypes[arch] is needlessly a dictionary.  Update inttypes[arch] to be a list
of tuples rather than a dictionary, and process them in list order.

Reported-by: George Dunlap <george.dunlap@eu.citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/include/xen-foreign/mkchecker.py
tools/include/xen-foreign/mkheader.py