@romracer's fix to work in python 2.6