Skip to content

gh-84548: Document Windows specific behavior of abspath() and realpath() - #155388

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-84548-abspath-windows-docs
Aug 13, 2026
Merged

gh-84548: Document Windows specific behavior of abspath() and realpath()#155388
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-84548-abspath-windows-docs

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

On Windows abspath() is not equivalent to normpath(join(os.getcwd(), path)), as the documentation says: the path is normalized by the operating system, so a drive-relative path is resolved against the current directory of the specified drive, the drive letter is capitalized, and trailing dots and spaces are stripped.

realpath() returns the path in the case reported by the operating system, in particular with the capitalized drive letter. It was reported as a bug, but it is the intended behavior, because since 3.8 it queries the final path from the system.

…ealpath()

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.
@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels Aug 8, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Aug 8, 2026
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Aug 8, 2026
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33974060 | 📁 Comparing 55d3e8a against main (998b890)

  🔍 Preview build  

1 file changed
± library/os.path.html

@serhiy-storchaka
serhiy-storchaka merged commit 582a2d3 into python:main Aug 13, 2026
41 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Aug 13, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Aug 13, 2026

Copy link
Copy Markdown

GH-155673 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Aug 13, 2026
@bedevere-app

bedevere-app Bot commented Aug 13, 2026

Copy link
Copy Markdown

GH-155674 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 13, 2026
@bedevere-app

bedevere-app Bot commented Aug 13, 2026

Copy link
Copy Markdown

GH-155675 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Aug 13, 2026
@serhiy-storchaka
serhiy-storchaka deleted the gh-84548-abspath-windows-docs branch August 13, 2026 09:54
serhiy-storchaka added a commit that referenced this pull request Aug 13, 2026
…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 582a2d3)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this pull request Aug 13, 2026
…realpath() (GH-155388) (GH-155674)

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 582a2d3)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant