Fix Python 2 and PyPy compat