10000 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
Next Next commit
Address review feedback?
  • Loading branch information
barneygale committed May 13, 2024
commit fad9af4cfab58f59b24fc69762ad6f0d250a5efd
55 changes: 21 additions & 34 deletions Doc/library/pathlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1077,11 +1077,9 @@ call fails (for example because the path doesn't exist).

.. method:: Path.is_dir(*, follow_symlinks=True)

Return ``True`` if the path points to a directory, ``False`` if it points
to another kind of file.

``False`` is also returned if the path doesn't exist, or is a broken
symlink, or is inaccessible for any other reason.
Return ``True`` if the path points to an accessible directory, ``False``
otherwise. Use :meth:`Path.exists` to test if a path is accessible without
checking its type.

This method normally follows symlinks; to exclude symlinks to directories,
add the argument ``follow_symlinks=False``.
Expand All @@ -1092,11 +1090,9 @@ call fails (for example because the path doesn't exist).

.. method:: Path.is_file(*, follow_symlinks=True)

Return ``True`` if the path points 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, or is inaccessible for any other reason.
Return ``True`` if the path points to an accessible regular file, ``False``
otherwise. Use :meth:`Path.exists` to test if a path is accessible without
checking its type.

This method normally follows symlinks; to exclude symlinks, add the
argument ``follow_symlinks=False``.
Expand Down Expand Up @@ -1132,46 +1128,37 @@ call fails (for example because the path doesn't exist).

.. method:: Path.is_symlink()

Return ``True`` if the path points to a symbolic link, ``False`` otherwise.

``False`` is also returned if the path doesn't exist or is inaccessible for
any other reason.
Return ``True`` if the path points to an accessible symbolic link,
``False`` otherwise. Use :meth:`Path.exists` to test if a path is
accessible without checking its type.


.. method:: Path.is_socket()

Return ``True`` if the path points to a Unix socket (or a symbolic link
pointing to a Unix socket), ``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.
Return ``True`` if the path points to an accessible Unix socket, ``False``
otherwise. Use :meth:`Path.exists` to test if a path is accessible without
checking its type.


.. method:: Path.is_fifo()

Return ``True`` if the path points to a FIFO (or a symbolic link
pointing to a FIFO), ``False`` if it points to another kind of file.

``False`` is also returned if the path doesn't exist, or is a broken
symlink, or is inaccessible for any other reason.
Return ``True`` if the path points to an accessible FIFO, ``False``
otherwise 8357 . Use :meth:`Path.exists` to test if a path is accessible without
checking its type.


.. method:: Path.is_block_device()

Return ``True`` if the path points to a block device (or a symbolic link
pointing to a block device), ``False`` if it points to another kind of file.

``False`` is also returned if the path doesn't exist, or is a broken
symlink, or is inaccessible for any other reason.
Return ``True`` if the path points to an accessible block device, ``False``
otherwise. Use :meth:`Path.exists` to test if a path is accessible without
checking its type.


.. method:: Path.is_char_device()

Return ``True`` if the path points to a character device (or a symbolic link
pointing to a character device), ``False`` if it points to another kind of file.

``False`` is also returned if the path doesn't exist, or is a broken
symlink, or is inaccessible for any other reason.
Return ``True`` if the path points to an accessible character device,
``False`` otherwise. Use :meth:`Path.exists` to test if a path is
accessible without checking its type.


.. method:: Path.iterdir()
Expand Down
0