Refactored out python 2.7 specific code