added better error handling for badly coded *.py documents