[py] make tmpo compatible with Python 3.x