Fix a Python 2 compatibility bug