Added PyInt_CheckExact for python < 3 and error check for PyLong_AsLong