Skip to content

Redundant File ..., line N block in SyntaxError output #14994

Open

Description

@SemTiOne

What's the problem this feature will solve?

Since #14899 the crash line already carries file:line:col, making the E-block's File/source/caret lines redundant:

E     File "package/lib.py", line 1
E       def broken(:
E                  ^
E   SyntaxError: invalid syntax
package/lib.py:1:12: SyntaxError: invalid syntax

Describe the solution you'd like

Omit the File block when the crash line carries the error's own file+line, keep it on the fallback path so no info is ever lost.

Alternative Solutions

Leave as is (stdlib default).

Additional context

Deferred from #14899. Related: #2388.

Activity

  1. avenet commented on Oct 16, 2026

    @avenet

    Proposed scope for this follow-up (after #14899):

    • Only strip the redundant File "...", line N header during collection (importtestmodule), and only when the file:line:col crash line is appended (reprcrash.column is not None).
    • Keep the source and caret lines (def broken(: / ^) — they are the only place the user's code appears in a collection error.
    • Leave runtime --tb=long/--tb=short unchanged: there the location line is still the test frame, so the File line is not redundant.
    • Leave the fallback path (no column) and ExceptionInfo.exconly / --tb=native unchanged.

    Target collection output:

    E       def broken(:
    E                  ^
    E   SyntaxError: invalid syntax
    package/lib.py:1:12: SyntaxError: invalid syntax
    

    Does this scope look right before a PR?

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