Python version compatibility.
Merge https://gist.github.com/a7f552e8b1fced1bc996