GeezerVison is showing github.com — Pathlib is_* functions do not fail in case of errno=EIO · Issue #160959 · python/cpython
Pathlib is_* functions do not fail in case of errno=EIO #160959DescriptionBug 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. Activitychanged the title [-]Ptahlib function do not fail in case of errno=EIO[/-] [+]Pathlib is_* functions do not fail in case of errno=EIO[/+] on Oct 30, 2026picnixz commented on Oct 30, 2026 This will be a breaking change. Is the behavior inconsistent with other functions or oa.path.* ones? socketpair commented on Oct 30, 2026 ContributorAuthor More actions @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 commented on Oct 30, 2026
Yes, it is inconsistent with pathlib's own previous behavior.
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.islink can raise EIO while Pathlib.islink cannot? what's important to me is that os.path* functions and pathlib do the same unless told otherwise.
I'm ok with a strict keyword 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 to os.path.ismount.
cc @zooba @barneygale @serhiy-storchaka @encukou ronaldoussoren commented on Oct 30, 2026 The documentation mentions this is an intentional change and consistent with the os.path.is* functions:
Changed in version 3.14: The methods given above now return False instead of raising any OSError exception from the operating system. In previous versions, some kinds of OSError exception are raised, and others suppressed. The new behaviour is consistent with os.path.exists(), os.path.isdir(), etc. Use stat() to retrieve the file status without suppressing exceptions.
Reacted by Коренберг Марк socketpair commented on Oct 31, 2026 ContributorAuthor More actions That's pity :(
So, I suggest strict= option for these functions. And probably the same for os.path.xxxx picnixz commented on 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.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|