Add support for Python 3 syntax.

This fixes the source so it runs under python 3, but doesn't fix
the non-deterministic-list-ordering issue in the tests resulting
from my use of lists to represent what are effectively sets.

Change-Id: I20bc524c0df3cf68a96a730e2cf8cfc8f41d2752