From 0185f34ddcf07b78feb6ac666fbfd4615d26b028 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 18 Sep 2018 11:28:51 +0300 Subject: 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. --- Lib/macpath.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Lib/macpath.py') diff --git a/Lib/macpath.py b/Lib/macpath.py index aacf7235b0..9a12d2feee 100644 --- a/Lib/macpath.py +++ b/Lib/macpath.py @@ -138,7 +138,7 @@ def lexists(path): try: st = os.lstat(path) - except OSError: + except (OSError, ValueError): return False return True -- cgit v1.2.1