May I ask why you need to check the python syntax before execution? Can't you just check the code separately before adding it to your program? Why is letting
exec
just fail not ok?