Python Editor: error output doesn't say which file failed, and the line number is wrong · Issue #663 · emsec/hal · GitHub
Skip to content

Python Editor: error output doesn't say which file failed, and the line number is wrong #663

Open

Description

@horhulenko

Describe the bug
When a script from the Python Editor raises an exception, the console prints:

<Execute Python Editor content>
NameError: name 'x' is not defined

At:
  <string>(2): <module>

Two problems with that:

  • It doesn't say which tab/file was executed. With several scripts open (explore.py, quirk_a.py, quirk_b.py), I can't tell from the output which one failed.
  • The line number is wrong. quirk_b.py contains a single line, print(x), but the error points to line 2.

To Reproduce

  1. Open HAL.
  2. Open the Python Editor and create a new tab, e.g. quirk_b.py.
  3. Put exactly one line in it:
print(x)
  1. Run the editor content.
  2. The console prints <string>(2): <module> — no file name, and line 2 in a one-line file.

Expected behavior
A normal Python traceback naming the file, the line and the offending source line:

Traceback (most recent call last):
  File "quirk_b.py", line 1, in <module>
    print(x)
          ^
NameError: name 'x' is not defined

Screenshots

Image

Desktop (please complete the following information):

  • OS: Windows 11 Pro (10.0.26300)
  • Version: 4.5.0 (v4.5.0-147-gff98e36c6)

Additional context
Would a plain Python traceback be preferable here, or is the current short form intentional? Even keeping the short form, the file name and a correct line number would help a lot — right now the offset makes it hard to find the error in longer scripts.

Activity

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