Skip to content

gh-118158: Fix missing newline in py_compile CLI error output#149008

Merged
itamaro merged 8 commits into
python:mainfrom
yuanx749:py-compile-newline
Jun 16, 2026
Merged

gh-118158: Fix missing newline in py_compile CLI error output#149008
itamaro merged 8 commits into
python:mainfrom
yuanx749:py-compile-newline

Conversation

@yuanx749

@yuanx749 yuanx749 commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Fix gh-118158.

The old main() added a trailing newline to error messages (bpo-23811), which was lost when it was refactored to use argparse.

The issue is still reproducible on main. Since this was reported about two years ago and there did not appear to be a PR, I went ahead and opened this fix.

@sepehr-rs sepehr-rs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm the fix works:

sepehr@debian:~$ ./python -m py_compile test.py
Sorry: IndentationError: unexpected indent (test.py, line 1)
sepehr@debian:~$ 

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think it’s standard to add Contributed by in the news entry, and I haven’t seen other CPython issues doing that. But I’ve only started contributing here recently, so I could be missing some context.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@itamaro itamaro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks for the fix!

@itamaro itamaro merged commit 7edcaed into python:main Jun 16, 2026
56 checks passed
@yuanx749 yuanx749 deleted the py-compile-newline branch June 16, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

py_compile CLI error message missing newline

3 participants