Sujet : Re: pathlib.Path.is_file vs os.path.isfile difference
De : grant.b.edwards (at) *nospam* gmail.com (Grant Edwards)
Groupes : comp.lang.pythonDate : 09. Mar 2024, 01:39:51
Autres entêtes
Message-ID : <mailman.75.1709941192.3452.python-list@python.org>
References : 1 2 3 4
User-Agent : slrn/1.0.3 (Linux)
On 2024-03-08, Thomas Passin via Python-list <
python-list@python.org> wrote:
>
Hi, I tested this with Python 3.8. Good to know that this was fixed!
>
We just learned a few posts back that it might be specific to Linux; I ran it on Windows.
On Linux, the limit is imposed by the filesystem. Most of the "real"
filesystems on Linux have a 255 character limit, a few support 256,
and some of the legacy filesystems have lower limits. Reiser4 is the
only one that's even remotely common which supports more than 256 --
according to
https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limitsit supports filenames up to 3976 bytes long.
NB: The behavior when the limit is exceeded might also vary from one
filesystem to another.
In any case, the pathlib docs for is_file() are explicit: any errors
from the underlying OS and libraries will be propogated. There is
nothing to fix.
https://docs.python.org/3/library/pathlib.html#pathlib.Path.is_file Path.is_file()
Return True if the path points to a regular file (or a symbolic
link pointing to a regular file), False if it points to another
kind of file.
False is also returned if the path doesn’t exist or is a broken
symlink; other errors (such as permission errors) are propagated.