← 输入框|github.com|刷新
Skip to content

SyntaxError: invalid syntax -- e.g. "for i range(360):" #112

Closed

Description

@bittner

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.

Activity

  1. cool-RR commented on Sep 25, 2018

    @cool-RR
    Member
  2. bittner commented on Sep 25, 2018

    @bittner
    MemberAuthor

    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!

  3. cool-RR commented on Sep 25, 2018

    @cool-RR
    Member
  4. bittner commented on Oct 2, 2018

    @bittner
    MemberAuthor

    Cool! 👍

    Awesome fix!

  5. bittner commented on Oct 3, 2018

    @bittner
    MemberAuthor

    This removes one blocker for #85.

  6. added a commit that references this issue on May 24, 2022
    64fa525
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions