Fix the code to work with Python2.6

It was previously using some features introduced in Python2.7.

Change-Id: I3b4b2895f231cf98235efd16f65eb123db8a9157