python / python/cpython

properly define what "canonical" means in `os.path.realpath`

Open
#134,639 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Documentation

The documentation says:
https://github.com/python/cpython/blob/2fd09b011031f3c00c342b44e02e2817010e507c/Doc/library/os.path.rst?plain=1#L406-L409

So it merely mentions symlink resolution, but not what else it means (if anything).

It does however mention that whatever it does is OS dependent:
https://github.com/python/cpython/blob/2fd09b011031f3c00c342b44e02e2817010e507c/Doc/library/os.path.rst?plain=1#L416-L418

IMO, it should be clearly documented what it does or at least:

  • what it guarantees to the least (For example will the pathname be absolute? Will it be normalised?)
    and/or:
  • which OS function it’s identical to, like on POSIX where that would probably realpath(), and whether there are differences to that

Especially since IMO "canonical" pathname (though I think it has no formal definition, or is there anything in POSIX?) means rather just that there are no symlinks left, i.e. that the file is "reached" by its true (=canonical) name.

But that could still be a relative pathname, and perhaps even one that is not normalised.

Cheers,
Chris.

Linked PRs
  • gh-134755

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Doc/library/os.path.rst at the cited lines 406-409 and 416-418, then compare the POSIX realpath() reference linked in the issue. Document the minimum guarantees of os.path.realpath and any OS-specific behavior or differences, with the wording making clear what “canonical” means.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.