You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some reason SyntaxError sometimes shows SyntaxError: invalid syntax (foo.enaml) rather than a more detailed error message. I am unable to track down the cause because I see in the unit tests that it should work. I ran core/parser/test_parser.py::test_syntax_error_traceback_correct_path and although the unit test fails on Python 3.11, it actually is generating the correct traceback, e.g:
from enaml.widgets.api import Container, Label
enamldf Foo:
pass
Then, enaml-run just prints out:
File "C:\Users\mmm\miniconda3\envs\psi4\Lib\site-packages\enaml\core\parser\base_python_parser.py", line 85, in parse
raise SyntaxError("invalid syntax", (self.filename, token.start, offset, token.line))
SyntaxError: invalid syntax (foo.enaml)
Running it a different way, e.g., via python test_foo.py containing the following:
import enaml
with enaml.imports():
import foo
Gives the same error (no information about what generated the error). I'm pretty stumped. I suspect this may be something related to Python 3.11 as the above code works fine on 3.10.
I dug into the base_python_parser.py code and I see if we update the code to match the new SyntaxError format where lineno, offset, end_lineno, end_offset are all provided, it generates a more informative error.
File "C:\Users\mmm\miniconda3\envs\psi4\Lib\site-packages\enaml\core\parser\base_python_parser.py", line 83, in parse
raise SyntaxError("invalid syntax", (self.filename, lineno, offset, token.line, end_lineno, end_offset))
File "foo.enaml", line 4
enamldf Foo:
I've submitted this patch, but I cannot figure out how to get a unit-test working to detect this. I think it may have to do with how Enaml imports the module?
The text was updated successfully, but these errors were encountered:
@frmdstryr I think IndentationError is a subclass of SyntaxError, which makes me wonder if it would be as simple as providing the same argument tuple as given to SyntaxError?
For some reason SyntaxError sometimes shows
SyntaxError: invalid syntax (foo.enaml)
rather than a more detailed error message. I am unable to track down the cause because I see in the unit tests that it should work. I rancore/parser/test_parser.py::test_syntax_error_traceback_correct_path
and although the unit test fails on Python 3.11, it actually is generating the correct traceback, e.g:However, if I create a
foo.enaml
file:Then,
enaml-run
just prints out:Running it a different way, e.g., via python
test_foo.py
containing the following:Gives the same error (no information about what generated the error). I'm pretty stumped. I suspect this may be something related to Python 3.11 as the above code works fine on 3.10.
I dug into the
base_python_parser.py
code and I see if we update the code to match the newSyntaxError
format where lineno, offset, end_lineno, end_offset are all provided, it generates a more informative error.I've submitted this patch, but I cannot figure out how to get a unit-test working to detect this. I think it may have to do with how Enaml imports the module?
The text was updated successfully, but these errors were encountered: