GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use a better python problem matcher by eric-wieser · Pull Request #420 · actions/setup-python

Conversation

@eric-wieser

@eric-wieser eric-wieser commented Jun 7, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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

  • Problem matchers #4

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.
    There are no existing tests for this feature, nor do I know if it is even possible to test.
    However, I tested this matcher in another action at https://github.com/sigproc-classrooms/sf2_competition_template/runs/6746359679?check_suite_focus=true#step:6:38, where you can see that it has correctly found an error that would not have previously matched.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@eric-wieser
Use a better python problem matcher
82009b3
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
eric-wieser requested a review from a team June 7, 2022 17:25
@brcrista
brcrista requested review from a team and removed request for a team January 4, 2023 17:43
@v-chiranjib-swain

v-chiranjib-swain commented Sep 16, 2026

Copy link
Copy Markdown

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

2 participants

@eric-wieser @v-chiranjib-swain
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.