Make recent changes compatible with Python 2