[1.7.x] Fix Python 3 incompatability