Skip to content

gh-109714: Pass the file name and a message when raising OSError subclasses - #156441

Draft
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:oserror-filename-argument
Draft

gh-109714: Pass the file name and a message when raising OSError subclasses#156441
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:oserror-filename-argument

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Aug 27, 2026

Copy link
Copy Markdown
Member

Depends on #156430 for the filename keyword argument.

  • Pass the file name as the filename argument instead of interpolating it into the message, so that it is available as the filename attribute: in shutil, logging.config, turtle, zipfile.Path and importlib.resources.
  • Give an explicit message where the one derived from errno would be misleading: "timed out" for timeouts which are not connection timeouts (asyncio, concurrent.futures, multiprocessing), and "No such resource" in importlib.resources.
  • In Tools, which is run with older Pythons too, pass errno explicitly.
  • Add _PyErr_SetOSErrorWithMessage() for raising an OSError subclass with an errno which is not the default one of the class — PermissionError with EINVAL in remote_debug.h.

…r subclasses

* Pass the file name as the filename argument instead of interpolating it
  into the message, so that it is available as the filename attribute:
  in shutil, logging.config, turtle, zipfile.Path and importlib.resources.
* Give an explicit message where the one derived from errno would be
  misleading: "timed out" for timeouts which are not connection timeouts,
  and "No such resource" in importlib.resources.
* In Tools, which is run with older Pythons too, pass errno explicitly.
* Add _PyErr_SetOSErrorWithMessage() for raising an OSError subclass with
  an errno which is not the default one of the class.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant