use PyLong_AsVoidPtr as suggested by pv
check the return value of PyLong_AsVoidPtr for NULL