summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorBarney Gale <barney.gale@gmail.com>2024-01-13 07:36:05 (GMT)
committerGitHub <noreply@github.com>2024-01-13 07:36:05 (GMT)
commite4ff131e01184b68d868cfd241a03f8b7d2e0ff9 (patch)
tree0292c431d2dd38f47a265d1d25d961ef86ec43b7 /Doc
parentdac1da21218a406652b35919aa2118cc32d4c65a (diff)
downloadcpython-e4ff131e01184b68d868cfd241a03f8b7d2e0ff9.zip
cpython-e4ff131e01184b68d868cfd241a03f8b7d2e0ff9.tar.gz
cpython-e4ff131e01184b68d868cfd241a03f8b7d2e0ff9.tar.bz2
GH-44626, GH-105476: Fix `ntpath.isabs()` handling of part-absolute paths (#113829)
On Windows, `os.path.isabs()` now returns `False` when given a path that starts with exactly one (back)slash. This is more compatible with other functions in `os.path`, and with Microsoft's own documentation. Also adjust `pathlib.PureWindowsPath.is_absolute()` to call `ntpath.isabs()`, which corrects its handling of partial UNC/device paths like `//foo`. Co-authored-by: Jon Foster <jon@jon-foster.co.uk>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/os.path.rst8
-rw-r--r--Doc/whatsnew/3.13.rst7
2 files changed, 13 insertions, 2 deletions
diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst
index 95933f5..3cab7a2 100644
--- a/Doc/library/os.path.rst
+++ b/Doc/library/os.path.rst
@@ -239,12 +239,16 @@ the :mod:`glob` module.)
.. function:: isabs(path)
Return ``True`` if *path* is an absolute pathname. On Unix, that means it
- begins with a slash, on Windows that it begins with a (back)slash after chopping
- off a potential drive letter.
+ begins with a slash, on Windows that it begins with two (back)slashes, or a
+ drive letter, colon, and (back)slash together.
.. versionchanged:: 3.6
Accepts a :term:`path-like object`.
+ .. versionchanged:: 3.13
+ On Windows, returns ``False`` if the given path starts with exactly one
+ (back)slash.
+
.. function:: isfile(path)
diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst
index 59b9281..05b9b87 100644
--- a/Doc/whatsnew/3.13.rst
+++ b/Doc/whatsnew/3.13.rst
@@ -307,6 +307,13 @@ os
:c:func:`!posix_spawn_file_actions_addclosefrom_np`.
(Contributed by Jakub Kulik in :gh:`113117`.)
+os.path
+-------
+
+* On Windows, :func:`os.path.isabs` no longer considers paths starting with
+ exactly one (back)slash to be absolute.
+ (Contributed by Barney Gale and Jon Foster in :gh:`44626`.)
+
pathlib
-------