Skip to content

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

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-84548-abspath-windows-docs
Open

gh-84548: Document Windows specific behavior of abspath() and realpath()#155388
serhiy-storchaka wants to merge 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review docs Documentation in the Doc dir 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 skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant