Skip to content

Commit 6e4aa89

Browse files
[3.15] gh-84548: Document Windows specific behavior of abspath() and realpath() (GH-155388) (#155673)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 50c4698 commit 6e4aa89

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Doc/library/os.path.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ the :mod:`glob` module.)
5959
Return a normalized absolutized version of the pathname *path*. On most
6060
platforms, this is equivalent to calling ``normpath(join(os.getcwd(), path))``.
6161

62+
On Windows the path is normalized by the operating system,
63+
therefore the result can differ from ``normpath(join(os.getcwd(), path))``.
64+
A drive-relative path is resolved against the current directory
65+
of the specified drive, and the drive letter is capitalized.
66+
Trailing dots and spaces are stripped.
67+
For example::
68+
69+
>>> os.path.abspath('c:spam')
70+
'C:\\Temp\\spam'
71+
>>> os.path.abspath('c:/temp/spam. . .')
72+
'c:\\temp\\spam'
73+
6274
.. seealso:: :func:`os.path.join` and :func:`os.path.normpath`.
6375

6476
.. versionchanged:: 3.6
@@ -435,6 +447,9 @@ the :mod:`glob` module.)
435447
links encountered in the path (if they are supported by the operating
436448
system). On Windows, this function will also resolve MS-DOS (also called 8.3)
437449
style names such as ``C:\\PROGRA~1`` to ``C:\\Program Files``.
450+
The returned path uses the case reported by the operating system,
451+
which can differ from the case of *path*,
452+
in particular the drive letter is capitalized.
438453

439454
By default, the path is evaluated up to the first component that does not
440455
exist, is a symlink loop, or whose evaluation raises :exc:`OSError`.

0 commit comments

Comments
 (0)