Skip to content

gh-153967: handle invalid file object in argparse._print_message#153969

Open
ptim0626 wants to merge 11 commits into
python:mainfrom
ptim0626:argparse-invalid-file-error
Open

gh-153967: handle invalid file object in argparse._print_message#153969
ptim0626 wants to merge 11 commits into
python:mainfrom
ptim0626:argparse-invalid-file-error

Conversation

@ptim0626

@ptim0626 ptim0626 commented Jul 18, 2026

Copy link
Copy Markdown

The fix for the above issue, which raises a ValueError if an invalid file is explicitly passed to argparse.print_usage and argparse.print_help. Tests added.

@bedevere-app

bedevere-app Bot commented Jul 18, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@python-cla-bot

python-cla-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

Comment thread Lib/test/test_argparse.py
Comment thread Lib/test/test_argparse.py Outdated
Comment thread Lib/argparse.py
@ZeroIntensity

Copy link
Copy Markdown
Member

This is also a user-facing change; please add a news entry.

@bedevere-app

bedevere-app Bot commented Jul 18, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app

bedevere-app Bot commented Jul 18, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@ptim0626

Copy link
Copy Markdown
Author

This is also a user-facing change; please add a news entry.

Thanks, and this was added.

Comment thread Misc/NEWS.d/next/Library/2026-07-18-16-05-38.gh-issue-153967.-OUNXe.rst Outdated
@ptim0626

Copy link
Copy Markdown
Author

Now I have no idea why test_ctypes failed in the CI...

@ZeroIntensity

Copy link
Copy Markdown
Member

That would be #154106. I just updated the branch, which should fix it.

@ptim0626

Copy link
Copy Markdown
Author

The merge fixed the test_ctypes but the sanitizer build failed with test_external_inspection.

@chris-eibl

chris-eibl commented Jul 19, 2026

Copy link
Copy Markdown
Member

No worries. test_external_inspection is a known flaky test. Also the readthedocs hiccuped - I hit "update branch" to trigger CI again and hope for the best :)

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

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants