`PyLong_AsLong` can raise an overflow error and returns -1 in that case, so when the result is -1 you need to check for a possible error. Unfortunately there seems to be no masked version of this function. I'm not sure of the best way to handle the big `PyLong`s, maybe mask them? That would be consistent.
```
In [1]: a = 2**100 + 1

In [2]: a & 0xff
Out[2]: 1L

```

Also, both Python 2 and Python 3 have `PyLong`, so the `PyLong_CheckExact` check should always be made and only the `PyInt_CheckExact` case should depend on Python < 3