Fix Python infinite loop parse_dammit bugs

Fix for incomplete function and class definitions resulting in infinite
loops.