Pathlib is_* functions do not fail in case of errno=EIO #160959
Copy link
Copy link
Closed as not planned
Labels
pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtopic-pathlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-featureA feature request or enhancementA feature request or enhancement
Description
Bug report
Pathlib functions do not fall with exception if they can not check. For example, .is_mount() will say False on mountpoint with failed FS. The most correct way - is to raise an Exception is check can not be done. EIO means "I don't know", not "this is not a mountpoint". The same with other is_* (like is_dir(), is_file() и is_symlink())
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
The same: mkdir(exist_ok=True) - will silently return on EIO. Any EIO must not be swallowed, as I think.
Metadata
Metadata
Assignees
Labels
pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtopic-pathlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortype-featureA feature request or enhancementA feature request or enhancement
Activity
[-]Ptahlib function do not fail in case of errno=EIO[/-][+]Pathlib is_* functions do not fail in case of errno=EIO[/+]picnixz commentedon Oct 30, 2026
This will be a breaking change. Is the behavior inconsistent with other functions or oa.path.* ones?
socketpair commentedon Oct 30, 2026
@picnixz
Yes, it is inconsistent with pathlib's own previous behavior.
Up to 3.13, Path.exists()/is_*() suppressed only errors that genuinely mean
"no" (ENOENT, ENOTDIR, EBADF, ELOOP); EIO, EACCES etc. propagated. In 3.14
(gh-101357 / gh-118243) this was widened to all OSError as a side effect of
a Windows performance optimization. So the breaking change has already
happened; restoring the old behavior would fix a regression.
The principle: if the check could not be done, there is no correct boolean
answer, so raise. EIO means "I don't know", not "no". Returning False hides
real problems like a failing disk or a dead NFS/FUSE mount.
Proposal: restore the strict behavior by default. If that's not acceptable,
add a keyword-only strict= parameter (as eryksun suggested in gh-101357).
picnixz commentedon Oct 30, 2026
I meant, is it inconsistent with existing behavior of other functions. What is preferrable is whether this changes with respect to
os.path.is*functions, i.e.os.path.islinkcan raise EIO whilePathlib.islinkcannot? what's important to me is thatos.path*functions andpathlibdo the same unless told otherwise.I'm ok with a
strictkeyword though (we have some strict policy that was added in 3.15). However, we won't change 3.14 I believe. AFAICT, ismount() was not affected by that change and forwarded toos.path.ismount.cc @zooba @barneygale @serhiy-storchaka @encukou
ronaldoussoren commentedon Oct 30, 2026
The documentation mentions this is an intentional change and consistent with the
os.path.is*functions:socketpair commentedon Oct 31, 2026
That's pity :(
So, I suggest strict= option for these functions. And probably the same for
os.path.xxxxpicnixz commentedon Oct 31, 2026
Please open a separate issue for that to indicate which functions should be modified. Strict policy already exists in some os.path functions (added in 3.15) so we may have some conflicts of notations.