Closed JulienPalard closed 3 years ago
there's an infinity of ways to SyntaxError, trying to handle them all may not be a sane idea... tell me :)
Given the original goal I had in mind and seeing how much further I have gone with no obvious end in sight ..., it is legitimate to question my sanity! ;-)
For SyntaxError: invalid syntax
cases, I have adopted the following approach:
>>> print(1/2) =
Traceback (most recent call last):
File "<friendly-console:3>", line 1
print(1/2) =
^
SyntaxError: invalid syntax
>>> s = _get_statement()
>>> s.bad_token
type=54 (OP) string='=' start=(1, 11) end=(1, 12) line='print(1/2) = \n'
>>>
If I reproduced the essence of this example correctly, I should have been able to identify and fix it. Checking my code, I have not yet considered deleting tokens, which appears to be the problem in this case (extra =
).
This has been taken care of in the latest version.
I'm always amazed how fast you fix my issues, thanks André!
I really don't know if this is the kind of report you want, I mean : there's an infinity of ways to SyntaxError, trying to handle them all may not be a sane idea... tell me :)
Here what I've seen today (yes, the student "wrote" the spaces up to the 80th column):
Python exception
A
SyntaxError
occurs when Python cannot understand your code.Python could not understand the code in the file 'solution.py' beyond the location indicated by ^.
Currently, I cannot guess the likely cause of this error. Try to examine closely the line indicated as well as the line immediately above to see if you can identify some misspelled word, or missing symbols, like (, ), [, ], :, etc.
Unless your code uses type annotations, which are beyond our scope, if you think that this is something which should be handled by friendly, please report this case to https://github.com/aroberge/friendly/issues