summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-09-18 08:28:51 (GMT)
committerGitHub <noreply@github.com>2018-09-18 08:28:51 (GMT)
commit0185f34ddcf07b78feb6ac666fbfd4615d26b028 (patch)
treea27f02f0095d5a7fb1fcbd539114b3a74fb4fcc7 /Doc
parent7bdf28265aa371b39f82dfc6562635801aff15a5 (diff)
downloadcpython-0185f34ddcf07b78feb6ac666fbfd4615d26b028.zip
cpython-0185f34ddcf07b78feb6ac666fbfd4615d26b028.tar.gz
cpython-0185f34ddcf07b78feb6ac666fbfd4615d26b028.tar.bz2
bpo-33721: Make some os.path functions and pathlib.Path methods be tolerant to invalid paths. (#7695)
Such functions as os.path.exists(), os.path.lexists(), os.path.isdir(), os.path.isfile(), os.path.islink(), and os.path.ismount() now return False instead of raising ValueError or its subclasses UnicodeEncodeError and UnicodeDecodeError for paths that contain characters or bytes unrepresentative at the OS level.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/os.path.rst8
-rw-r--r--Doc/library/pathlib.rst12
-rw-r--r--Doc/whatsnew/3.8.rst25
3 files changed, 44 insertions, 1 deletions
diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst
index 36bb21c..5a0b178 100644
--- a/Doc/library/os.path.rst
+++ b/Doc/library/os.path.rst
@@ -55,6 +55,14 @@ the :mod:`glob` module.)
* :mod:`macpath` for old-style MacOS paths
+.. versionchanged:: 3.8
+
+ :func:`exists`, :func:`lexists`, :func:`isdir`, :func:`isfile`,
+ :func:`islink`, and :func:`ismount` now return ``False`` instead of
+ raising an exception for paths that contain characters or bytes
+ unrepresentable at the OS level.
+
+
.. function:: abspath(path)
Return a normalized absolutized version of the pathname *path*. On most
diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
index ec604f6..fc19300 100644
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -638,7 +638,17 @@ Methods
Concrete paths provide the following methods in addition to pure paths
methods. Many of these methods can raise an :exc:`OSError` if a system
-call fails (for example because the path doesn't exist):
+call fails (for example because the path doesn't exist).
+
+.. versionchanged:: 3.8
+
+ :meth:`~Path.exists()`, :meth:`~Path.is_dir()`, :meth:`~Path.is_file()`,
+ :meth:`~Path.is_mount()`, :meth:`~Path.is_symlink()`,
+ :meth:`~Path.is_block_device()`, :meth:`~Path.is_char_device()`,
+ :meth:`~Path.is_fifo()`, :meth:`~Path.is_socket()` now return ``False``
+ instead of raising an exception for paths that contain characters
+ unrepresentable at the OS level.
+
.. classmethod:: Path.cwd()
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index 38b8623..1c129a7 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -112,6 +112,31 @@ New Modules
Improved Modules
================
+os.path
+-------
+
+:mod:`os.path` functions that return a boolean result like
+:func:`~os.path.exists`, :func:`~os.path.lexists`, :func:`~os.path.isdir`,
+:func:`~os.path.isfile`, :func:`~os.path.islink`, and :func:`~os.path.ismount`
+now return ``False`` instead of raising :exc:`ValueError` or its subclasses
+:exc:`UnicodeEncodeError` and :exc:`UnicodeDecodeError` for paths that contain
+characters or bytes unrepresentable at the OS level.
+(Contributed by Serhiy Storchaka in :issue:`33721`.)
+
+pathlib
+-------
+
+:mod:`pathlib.Path` methods that return a boolean result like
+:meth:`~pathlib.Path.exists()`, :meth:`~pathlib.Path.is_dir()`,
+:meth:`~pathlib.Path.is_file()`, :meth:`~pathlib.Path.is_mount()`,
+:meth:`~pathlib.Path.is_symlink()`, :meth:`~pathlib.Path.is_block_device()`,
+:meth:`~pathlib.Path.is_char_device()`, :meth:`~pathlib.Path.is_fifo()`,
+:meth:`~pathlib.Path.is_socket()` now return ``False`` instead of raising
+:exc:`ValueError` or its subclass :exc:`UnicodeEncodeError` for paths that
+contain characters unrepresentable at the OS level.
+(Contributed by Serhiy Storchaka in :issue:`33721`.)
+
+
Optimizations
=============