Skip to content

gh-143201: C warnings writes the full source line instead of the truncated one - #161454

Open
cmaloney wants to merge 4 commits into
python:mainfrom
cmaloney:warnings_truncated_sourceline
Open

cmaloney wants to merge 4 commits into
python:mainfrom
cmaloney:warnings_truncated_sourceline

Conversation

@cmaloney

@cmaloney cmaloney commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

The truncated was created but never used. Use it, and check for errors when writing. Include a test.

Picks up from work by @AZero13

AZero13 and others added 2 commits November 5, 2026 13:37
…truncated one

The truncated object is meant to be written instead.
Write the two-space indent before the stripped source line, matching
_Py_DisplaySourceLine() and the Python implementation, and test the C
show_warning() fallback with a loader-provided indented source line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread Python/_warnings.c Resolved
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread Lib/test/test_warnings/__init__.py Resolved
…ings

Address review: strip both sides, run the test on all implementations,
and move the NEWS entry to Library.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cmaloney

Copy link
Copy Markdown
Contributor Author

@vstinner could you take a look, updates the code from #143201 to match the Python per your comment (#157043 (comment)).

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

Labels

awaiting core review type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants