Python: return hooks with PyLong_FromVoidPtr

Fixes #685