Make handling of PyNumber_Index more robust