5566e6f2c8
In Python3, dict.keys() returns a view object rather than a list. This behaves differently in that changes to the dict also modify the view, and in that the view type interacts with various operators in different ways to lists. One universally correct transformation to preserve Python2 behaviour in Python3 would be to replace all instances of d.keys() with list(six.iterkeys(d)), and indeed we did. However, like many automatic transformations the results are usually unsightly, invariably inefficient, and frequently absurd. Not least because list(d.keys()) and indeed list(d) are also equivalent. This patch changes to using the simplest correct method of accessing the data we want in each case. This reverts or rewrites most of commit 4ace95ad47da7099191a06325c5d0b156fd54894. Change-Id: Iba3cf48246d8cbc958d8fb577cd700a218b0bebf