I'm using ast to get information from Python source files (as per the suggestion here). For this, I have extended ast.NodeVisitor
and it runs fine with most source files. However, I'm getting a
RuntimeError: maximum recursion depth exceeded while calling a Python object
exception when I use this on big classes (~2000 lines. Terrible practice. I know :) ). When I inspect the stack upon the crash, I see that there is indeed a very deep recursion going on, but it does not seem to be going in a loop. I.e., if the recursion would go on for some more, it'll complete successfully. Is there a way to fix this?
I'm not sure if this has anything to do with this, but this big class contains a large if ... elif ... elif ... elif ... else
statement.