Skip to content

Mark OSError.strerror as sometimes None - #12974

Merged
JelleZijlstra merged 1 commit into
python:mainfrom
brianschubert:stdlib-oserror-strerror
Nov 7, 2024
Merged

JelleZijlstra merged 1 commit into
python:mainfrom
brianschubert:stdlib-oserror-strerror

Conversation

@brianschubert

Copy link
Copy Markdown
Collaborator

Refs #9864, follows from #12910

Like OSError.errno, strerror can sometimes be None. Usually, both attributes are None at the same time.

Since we added None to errno, it probably makes sense to do the same for strerror.

@github-actions

github-actions Bot commented Nov 7, 2024

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@brianschubert

Copy link
Copy Markdown
Collaborator Author

I'm pleasantly surprised that there isn't a significant primer hit like there was with errno. Perhaps that's because strerror is often used in a string-formatting/printing context, where None would be legal anyway, e.g. raise MyCustomError(f"some message: {ex.strerror}").

@JelleZijlstra
JelleZijlstra merged commit dafd67c into python:main Nov 7, 2024
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.

2 participants