Use PyIndex_Check to typecheck int-like objects
Prevent silent integer overflow computing message counts