SyntaxError: invalid syntax -- e.g. "for i range(360):"
bittner opened this issue Β· comments
When entering some invalid Python code that throws a SyntaxError, e.g. for i range(360):
, then the application hangs. (At least, that's what's happening when launched via PyCharm.)
Process TurtleProcess-1:
Traceback (most recent call last):
File "/home/peter/Development/repos/PythonTurtle/src/shelltoprocess/console.py", line 74, in runsource
code = self.compile(source, filename, symbol)
File "/usr/lib/python3.6/codeop.py", line 168, in __call__
return _maybe_compile(self.compiler, source, filename, symbol)
File "/usr/lib/python3.6/codeop.py", line 99, in _maybe_compile
raise err1
File "/usr/lib/python3.6/codeop.py", line 87, in _maybe_compile
code1 = compiler(source + "\n", filename, symbol)
File "/usr/lib/python3.6/codeop.py", line 133, in __call__
codeob = compile(source, filename, symbol, self.flags, 1)
File "<console>", line 1
for i range(360):
^
SyntaxError: invalid syntax
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/home/peter/Development/repos/PythonTurtle/src/turtleprocess.py", line 257, in run
self.console.interact()
File "/home/peter/Development/repos/PythonTurtle/src/shelltoprocess/console.py", line 144, in interact
more = self.push(line)
File "/home/peter/Development/repos/PythonTurtle/src/shelltoprocess/console.py", line 50, in push
more = self.runsource(command, self.filename)
File "/home/peter/Development/repos/PythonTurtle/src/shelltoprocess/console.py", line 77, in runsource
self.showsyntaxerror(filename)
File "/home/peter/Development/repos/PythonTurtle/src/shelltoprocess/console.py", line 60, in showsyntaxerror
msg, (dummy_filename, lineno, offset, line) = value
TypeError: 'SyntaxError' object is not iterable
This error should be caught at application-level, and displayed to the user in the interactive console.
In the Python 2 version this doesn't crash the application. When I run the current code base with Python 3 from the terminal I get the same error as above. That means, we have an error that didn't exist before migrating to Python 3. π -- I'm really sorry!
Cool! π
Awesome fix!
This removes one blocker for #85.