8000 GH-101357: Suppress `OSError` from `pathlib.Path.exists()` and `is_*()` by barneygale · Pull Request #118243 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-101357: Suppress OSError from pathlib.Path.exists() and is_*() #118243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
exists() --> stat()
  • Loading branch information
barneygale committed May 14, 2024
commit 749731fffb5db9d0a3c24e2858a99b7d746529a5
16 changes: 9 additions & 7 deletions Doc/library/pathlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,8 @@ call fails (for example because the path doesn't exist).
.. method:: Path.exists(*, follow_symlinks=True)

Return ``True`` if the path points to an existing file or directory.
``False`` will be returned if the path is invalid, inaccessible or missing.
Use :meth:`Path.stat` to distinguish between these cases.

This method normally follows symlinks; to check if a symlink exists, add
the argument ``follow_symlinks=False``.
Expand Down Expand Up @@ -1079,7 +1081,7 @@ call fails (for example because the path doesn't exist).

Return ``True`` if the path points to a directory. ``False`` will be
returned if the path is invalid, inaccessible or missing, or if it points
to something other than a directory. Use :meth:`Path.exists` to distinguish
to something other than a directory. Use :meth:`Path.stat` to distinguish
between these cases.

This method normally follows symlinks; to exclude symlinks to directories,
Expand All @@ -1093,7 +1095,7 @@ call fails (for example because the path doesn't exist).

Return ``True`` if the path points to a regular file. ``False`` will be
returned if the path is invalid, inaccessible or missing, or if it points
to something other than a regular file. Use :meth:`Path.exists` to
to something other than a regular file. Use :meth:`Path.stat` to
distinguish between these cases.

This method normally follows symlinks; to exclude symlinks, add the
Expand Down Expand Up @@ -1133,38 +1135,38 @@ call fails (for example because the path doesn't exist).
Return ``True`` if the path points to a symbolic link, even if that symlink
is broken. ``False`` will be returned if the path is invalid, inaccessible
or missing, or if it points to something other than a symbolic link. Use
:meth:`Path.exists` to distinguish between these cases.
:meth:`Path.stat` to distinguish between these cases.


.. method:: Path.is_socket()

Return ``True`` if the path points to a Unix socket. ``False`` will be
returned if the path is invalid, inaccessible or missing, or if it points
to something other than a Unix socket. Use :meth:`Path.exists` to
to something other than a Unix socket. Use :meth:`Path.stat` to
distinguish between these cases.


.. method:: Path.is_fifo()

Return ``True`` if the path points to a FIFO. ``False`` will be returned if
the path is invalid, inaccessible or missing, or if it points to something
other than a FIFO. Use :meth:`Path.exists` to distinguish between these
other than a FIFO. Use :meth:`Path.stat` to distinguish between these
cases.


.. method:: Path.is_block_device()

Return ``True`` if the path points to a block device. ``False`` will be
returned if the path is invalid, inaccessible or missing, or if it points
to something other than a block device. Use :meth:`Path.exists` to
to something other than a block device. Use :meth:`Path.stat` to
distinguish between these cases.


.. method:: Path.is_char_device()

Return ``True`` if the path points to a character device. ``False`` will be
returned if the path is invalid, inaccessible or missing, or if it points
to something other than a character device. Use :meth:`Path.exists` to
to something other than a character device. Use :meth:`Path.stat` to
distinguish between these cases.


Expand Down
0