Skip to content

gh-134639: Clarify what "canonical" means in os.path.realpath #134755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ashm-dev
Copy link
Contributor

@ashm-dev ashm-dev commented May 26, 2025

Summary

This PR improves the documentation for os.path.realpath by clearly defining what a "canonical path" means. The current documentation only mentions symlink resolution but doesn't explain other aspects of canonicalization.

Details

The updated documentation now explicitly states that a canonical path:

  • Is an absolute path (always starts from the root of the filesystem)
  • Has all symbolic links resolved (if supported by the operating system)
  • Is normalized (redundant separators, '.' and '..' components removed)

It also clarifies platform-specific behavior:

  • On Windows: resolves MS-DOS (8.3) style names and junction points
  • On POSIX: roughly equivalent to the system's realpath() function

Related Issues

Closes #134639
Related to #134639


📚 Documentation preview 📚: https://cpython-previews--134755.org.readthedocs.build/

Improve documentation for os.path.realpath by clearly defining what a
"canonical path" means. The updated documentation now explicitly states
that a canonical path:
- Is an absolute path
- Has all symbolic links resolved
- Is normalized (redundant separators, '.' and '..' components removed)

Also clarify platform-specific behavior:
- On Windows: resolves MS-DOS (8.3) style names and junction points
- On POSIX: roughly equivalent to the system's realpath() function

Closes python#134639
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

properly define what "canonical" means in os.path.realpath
1 participant