When there are no syntax errors:
>>> symtable.symtable("guido = 1; rossum = 2", "code", "exec").get_symbols()
[<symbol 'rossum'>, <symbol 'guido'>]
When there are syntax errors:
>>> symtable.symtable("guido = 1; for", "code", "exec").get_symbols()
guido = 1; for
^
SyntaxError: invalid syntax
Is there a way to make this fault-tolerant? In other words, in the second example, is it possible to generate a symtable that has the "guido" symbol in it even though there is a syntax error elsewhere in the code?
I've tried looking around for modules that will turn python code with syntax errors into code that compiles (e.g., by removing bad statements from them), but I wasn't able to find anything.