Closed bburan closed 10 months ago
Seems like with the new parser indentation errors also do not provide the line or any context (like which file).
from enaml.widgets.api import Window, Container, Label
enamldef Main(Window): window:
Container:
Label:
text = "Hello!"
Just gives
# large traceback ommitted
File "/home/user/projects/enaml/enaml/core/parser/base_python_parser.py", line 104, in raise_indentation_error
raise IndentationError(msg)
IndentationError: expected an indented block
Your PR works well for syntax errors! Thanks!!
@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?
Closed by #530
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?