From ab5d78ce4141a6b3cd55588cdbe3cd3bd5242d5b Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Thu, 22 Apr 2021 13:30:29 -0700 Subject: [PATCH] bpo-35306: Avoid raising OSError from pathlib.Path.exists when passed an invalid filename (GH-25529) (cherry picked from commit 4696f1285d83dd7b69f459c63e14080b1f87f797) Co-authored-by: Steve Dower --- Lib/pathlib.py | 1 + .../next/Windows/2021-04-22-20-39-49.bpo-35306.F0Cg6X.rst | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 Misc/NEWS.d/next/Windows/2021-04-22-20-39-49.bpo-35306.F0Cg6X.rst diff --git a/Lib/pathlib.py b/Lib/pathlib.py index da51a4f500e8..756d389cfad3 100644 --- a/Lib/pathlib.py +++ b/Lib/pathlib.py @@ -39,6 +39,7 @@ _IGNORED_ERROS = (ENOENT, ENOTDIR, EBADF, ELOOP) _IGNORED_WINERRORS = ( 21, # ERROR_NOT_READY - drive exists but is not accessible + 123, # ERROR_INVALID_NAME - fix for bpo-35306 1921, # ERROR_CANT_RESOLVE_FILENAME - fix for broken symlink pointing to itself ) diff --git a/Misc/NEWS.d/next/Windows/2021-04-22-20-39-49.bpo-35306.F0Cg6X.rst b/Misc/NEWS.d/next/Windows/2021-04-22-20-39-49.bpo-35306.F0Cg6X.rst new file mode 100644 index 000000000000..af41b3ceacb6 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2021-04-22-20-39-49.bpo-35306.F0Cg6X.rst @@ -0,0 +1,2 @@ +Avoid raising errors from :meth:`pathlib.Path.exists()` when passed an +invalid filename. -- 2.47.3