GeezerVison is showing github.com — Use a better python problem matcher by eric-wieser · Pull Request #420 · actions/setup-python
Conversation
eric-wieser
commented
Jun 7, 2022
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Description:
The old matcher only worked if the error was raised with raise Exception('single quotes').
This represents a miniscule fraction of errors; for instance, l[37] on a short list l can raise IndexError, and any call to a builtin C function is not going to trace back to a raise call.
Instead, this just matches the first line without fail that comes after the context line.
Note that this is still not foolproof; in Python 3.10, SyntaxErrors are produced as
File "<stdin>", line 1
foo(x, z for z in range(10), t, w)
^^^^^^^^^^^^^^^^^^^^
SyntaxError: Generator expression must be parenthesized
This matcher will incorrectly pick up ^^^^^^^^^^^^^^^^^^^^ as the error message, but the previous behavior was to not pick up any error message at all.
As far as I can tell, this is impossible to handle correctly; the grammar of problem matchers is far too limiting.
Some other changes:
- Remove nonsensical double-escaping of
". " is not a regex character, it needs only to be escaped once for JSON
- Require the traceback to appear in the first column, as this is how python usually handles it. There is no way to track indentation between lines, but we are forced to make a choice between catching errors not caused by
raise (common) and catching errors which are printed by a custom handler (uncommon).
Related issue:
This follows on from
Check list:
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
The old matcher only worked if the error was raised with `raise Exception('single quotes')`.
This represents a miniscule fraction of errors; for instance, `l[37]` on a short list `l` can raise `IndexError`, and any call to a builtin C function is not going to trace back to a `raise` call.
Instead, this just matches the first line without fail that comes after the context line.
Note that this is still not foolproof; in Python 3.10, `SyntaxError`s are produced as
```
File "<stdin>", line 1
foo(x, z for z in range(10), t, w)
^^^^^^^^^^^^^^^^^^^^
SyntaxError: Generator expression must be parenthesized
```
This matcher will incorrectly pick up ` ^^^^^^^^^^^^^^^^^^^^` as the error message, but the previous behavior was to not pick up any error message at all.
As far as I can tell, this is impossible to handle correctly; the grammar of problem matchers is far too limiting.
|
@eric-wieser
Thanks for this improvement. Since this PR was opened, Python 3.11 introduced PEP 657, which added ^/~ location lines to runtime tracebacks. With the current matcher, these lines can be captured as the annotation message instead of the actual exception.
Would you be open to adding a second matcher layout that consumes the optional ^/~ line before capturing the exception, while keeping the existing layout for classic tracebacks?
It may also be worth changing the file capture from (.) to ([^"]) to avoid greedy matching.
We validated this approach with Python 3.10 and 3.14, including classic and PEP 657 tracebacks. This would preserve the original approach while covering modern Python tracebacks.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|