[Python-checkins] bpo-35306: Avoid raising OSError from pathlib.Path.exists when passed an invalid filename (GH-25529)
miss-islington
webhook-mailer at python.org
Thu Apr 22 16:25:18 EDT 2021
https://github.com/python/cpython/commit/1575ea01059b3ba836cdb62f01f0b6584d7756a7
commit: 1575ea01059b3ba836cdb62f01f0b6584d7756a7
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2021-04-22T13:25:08-07:00
summary:
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 <steve.dower at python.org>
files:
A Misc/NEWS.d/next/Windows/2021-04-22-20-39-49.bpo-35306.F0Cg6X.rst
M Lib/pathlib.py
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
index 5e3940bccc8ff..350f27e4a06de 100644
--- a/Lib/pathlib.py
+++ b/Lib/pathlib.py
@@ -39,6 +39,7 @@
_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 0000000000000..af41b3ceacb64
--- /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.
More information about the Python-checkins
mailing list