Replaced PyInt_As_Long with PyInt_AsLong and  errorchecking