https://github.com/python/cpython/commit/b90caeeab6d8d58f02166f70f8f65f6c51227a72 commit: b90caeeab6d8d58f02166f70f8f65f6c51227a72 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: serhiy-storchaka <[email protected]> date: 2026-08-13T10:00:06Z summary:
[3.13] gh-84548: Document Windows specific behavior of abspath() and realpath() (GH-155388) (GH-155675) On Windows abspath() resolves a drive-relative path against the current directory of the specified drive, capitalizes the drive letter and strips trailing dots and spaces, so the result can differ from normpath(join(os.getcwd(), path)). realpath() returns the path in the case reported by the operating system. (cherry picked from commit 582a2d3ebafa993234218470e5fbb490197d89e6) Co-authored-by: Serhiy Storchaka <[email protected]> files: M Doc/library/os.path.rst diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst index b9cfc527338a47..14bb3ba96b19c6 100644 --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -59,6 +59,18 @@ the :mod:`glob` module.) Return a normalized absolutized version of the pathname *path*. On most platforms, this is equivalent to calling ``normpath(join(os.getcwd(), path))``. + On Windows the path is normalized by the operating system, + therefore the result can differ from ``normpath(join(os.getcwd(), path))``. + A drive-relative path is resolved against the current directory + of the specified drive, and the drive letter is capitalized. + Trailing dots and spaces are stripped. + For example:: + + >>> os.path.abspath('c:spam') + 'C:\\Temp\\spam' + >>> os.path.abspath('c:/temp/spam. . .') + 'c:\\temp\\spam' + .. seealso:: :func:`os.path.join` and :func:`os.path.normpath`. .. versionchanged:: 3.6 @@ -427,6 +439,9 @@ the :mod:`glob` module.) links encountered in the path (if they are supported by the operating system). On Windows, this function will also resolve MS-DOS (also called 8.3) style names such as ``C:\\PROGRA~1`` to ``C:\\Program Files``. + The returned path uses the case reported by the operating system, + which can differ from the case of *path*, + in particular the drive letter is capitalized. By default, the path is evaluated up to the first component that does not exist, is a symlink loop, or whose evaluation raises :exc:`OSError`. _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
