I'm trying to make a frontend for the compile module in python.
Everything works just right, except when the file has mistakes in the code that lead to a syntax error.
It does raise the invalid syntax error in the terminal, but instead of executing the block inside the except statement, it goes on to the else block. look:
try: file = t1.get() py_compile.compile(file) except IOError: tkinter.messagebox.showerror("Error", "File not found") except UnicodeDecodeError: tkinter.messagebox.showerror("Error", "This is not python code") except SyntaxError: tkinter.messagebox.showerror("Error", "There is a syntax error in the code") else: time.sleep(2) tkinter.messagebox.showinfo("¡Successfully compiled!", "The file \n(%s)\n was compiled successfully" %file)