apigen: Fix function detection in Python 3