Omit redundant File block in SyntaxError output when crash line has location - #15085
Closed
Dextheking1 wants to merge 27 commits into
Closed
Dextheking1 wants to merge 27 commits into
Dextheking1 wants to merge 27 commits into
Conversation
Co-authored-by: Claude <noreply@anthropic.com>
…/SemTiOne/pytest into fix-2388-syntax-error-crash-line
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Bruno Oliveira <bruno@soliv.dev>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
…ocation When the crash line already carries the SyntaxError's own file:line:column (see pytest-dev#14899), the File "...", line N / source / caret block emitted by traceback.format_exception_only() in the E-lines is redundant. Drop it in ExceptionInfoFormatter.get_exconly, keeping it on the fallback path (no location info) so no information is lost. Closes pytest-dev#14994.
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stacked on #14899 (which makes the crash line carry the error's own
file:line:col); closes #14994.Before
After
Rationale
traceback.format_exception_only()emits aFile "...", line N/ source / caret block forSyntaxError, whichExceptionInfoFormatter.get_exconly()renders asE-lines. Once the crash line reports the error's ownfile:line:column(#14899), that block only repeats the same location, so it is now dropped inget_exconly()via a small_strip_syntax_error_file_block()helper (keeps the exception line itself verbatim; never strips when the exception line can't be identified).When the error does not carry usable location info (no filename/lineno/offset), the crash line falls back to the traceback entry and the block is kept, so no information is ever lost:
changelogdirectory (changelog/14994.improvement.rst).File ..., line Nblock in SyntaxError output #14994Closes #14994.