python / python/cpython

os.stat()’s follow_symlinks is a bit ambigously described

Open
#96,402 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Documentation

There are numerous functions which take a pathname and and argument like follow_symlinks.

For most of these, the argument follow_symlinks is not further explained in the function itself, but people will rather have to resort to https://docs.python.org/3/library/os.html#files-and-directories where things are rather exactly described.

However, the description of os.stat() has:

This function normally follows symlinks; to stat a symlink add the argument follow_symlinks=False, or use lstat().

Which is however only half correct, because what it actually means is:

When the last component of the path is a symbolic link, the function normally follows it. Symbolic links in the path that are not the last component, are always followed.

Similar, the paragraph below for windows, also uses wording that implies any name-surrogate reparse points, i.e. not only if the last pathname component is one.
No idea what Windows does, but if that's also wrong, it should be corrected accordingly. Also in the "Changed in" entry for that.

AFAICS, the other functions of os have it correctly described (by simply not describing it).

Thanks,
Chris.

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 with the os.stat() documentation and the linked Files and Directories section. Clarify that follow_symlinks applies to the last pathname component, then verify and correct the corresponding Windows wording and Changed in entry if needed; the documentation should accurately describe both behaviors.

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
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.