apigen: Fix function detection in Python 3
Merge pull request #1306 from stefanv/py3_apigen_fix

apigen: Fix function detection in Python 3