The `PyLong_AsUnsignedLongLong` version will never be negative. In this case you need to check `(unsigned long long)-1`, see the documentation at http://docs.python.org/3.1/c-api/long.html